/* ============================================================
   TIME AND WORK CALCULATOR — style.css
   Design: SpeedDistanceCalculator.com style
   ============================================================ */

:root {
  --navy:        #1a3a6b;
  --navy-dark:   #122b55;
  --navy-light:  #2a4d8a;
  --blue-accent: #2563eb;
  --blue-light:  #dbeafe;
  --page-bg:     #e8eef7;
  --card-bg:     #ffffff;
  --border:      #d1dae8;
  --text-main:   #1a1a2e;
  --text-body:   #374151;
  --text-muted:  #6b7280;
  --input-bg:    #f8fafc;
  --green:       #16a34a;
  --green-bg:    #f0fdf4;
  --green-border:#bbf7d0;
  --red:         #dc2626;
  --red-bg:      #fef2f2;
  --red-border:  #fca5a5;
  --tab-active:  #1a3a6b;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 4px rgba(26,58,107,.08), 0 2px 8px rgba(26,58,107,.06);
  --shadow-md:   0 4px 16px rgba(26,58,107,.10);
}

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: var(--blue-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

/* ── SKIP NAV ───────────────────────────────────────────────── */
.skip-nav {
  position: absolute; top: -100%; left: 16px; z-index: 9999;
  padding: 8px 18px; background: var(--navy); color: #fff;
  font-weight: 600; border-radius: 0 0 var(--radius) var(--radius);
  transition: top .2s;
}
.skip-nav:focus { top: 0; text-decoration: none; }

/* ── NOSCRIPT ───────────────────────────────────────────────── */
.noscript-banner {
  padding: 12px 20px; background: #fef3c7;
  border-bottom: 2px solid #f59e0b; text-align: center;
}

/* ── HEADER ─────────────────────────────────────────────────── */
.site-header { background: var(--navy); }

.header-top { padding: 14px 0 12px; }
.header-inner { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.logo-link {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none;
}
.logo-icon-wrap {
  width: 38px; height: 38px;
  background: #fff; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-text {
  font-size: 1.05rem; font-weight: 700;
  color: #fff; letter-spacing: -.01em;
}

.header-nav-bar {
  background: var(--navy-dark);
  border-top: 1px solid rgba(255,255,255,.1);
}
.header-nav-bar nav {
  display: flex; gap: 4px; padding: 0;
}
.header-nav-bar nav a {
  display: inline-block;
  padding: 10px 16px;
  color: rgba(255,255,255,.82);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
  border-radius: 0;
}
.header-nav-bar nav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

/* ── PAGE WRAP ──────────────────────────────────────────────── */
.page-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

/* ── AD BANNER ──────────────────────────────────────────────── */
.ad-banner {
  background: #fff;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}
.ad-inner {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    -45deg,
    #f0f4fa 0px, #f0f4fa 10px,
    #e8eef7 10px, #e8eef7 20px
  );
}
.ad-label {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 5px 18px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--text-muted);
}

/* ── TWO-COLUMN ─────────────────────────────────────────────── */
.main-cols {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

/* ── CALC CARD ──────────────────────────────────────────────── */
.calc-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}
.calc-title {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
  line-height: 1.2;
}
.calc-subtitle {
  font-size: .875rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}
.mode-tab {
  padding: 9px 18px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: -2px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.mode-tab:hover { color: var(--navy); background: var(--blue-light); }
.mode-tab.active {
  color: var(--navy);
  font-weight: 700;
  border-bottom: 2px solid var(--navy);
  background: #fff;
}

/* Mode Panels */
.mode-panel { display: flex; flex-direction: column; }
.mode-panel.hidden { display: none !important; }
.panel-desc {
  font-size: .875rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.55;
}

/* Field rows */
.workers-list { display: flex; flex-direction: column; gap: 12px; }
.worker-row {}
.field-row { display: flex; flex-direction: column; gap: 5px; }
.field-label {
  font-size: .825rem;
  font-weight: 600;
  color: var(--text-body);
}
.input-group {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.input-group input[type="number"] {
  flex: 1; min-width: 100px;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-main);
  transition: border-color .15s, box-shadow .15s;
  -moz-appearance: textfield;
}
.input-group input[type="number"]::-webkit-inner-spin-button,
.input-group input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
.input-group input[type="number"]:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,58,107,.12);
  background: #fff;
}
.input-group select {
  padding: 9px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  font-size: .85rem;
  color: var(--text-main);
  cursor: pointer;
  transition: border-color .15s;
}
.input-group select:focus { outline: none; border-color: var(--navy); }
.pipe-type { font-size: .82rem; }

.btn-remove {
  width: 30px; height: 30px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text-muted); font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-remove:hover { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }

.btn-add-row {
  margin-top: 12px; width: 100%;
  padding: 9px 16px;
  border: 1.5px dashed #93c5fd;
  border-radius: var(--radius);
  background: transparent;
  color: var(--blue-accent);
  font-size: .875rem; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn-add-row:hover { background: var(--blue-light); border-color: var(--blue-accent); }

/* Buttons */
.calc-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.btn-calculate {
  flex: 1;
  padding: 12px 24px;
  background: var(--navy);
  color: #fff; font-size: .95rem; font-weight: 700;
  border: none; border-radius: var(--radius);
  letter-spacing: .01em;
  transition: background .15s, box-shadow .15s, transform .1s;
  box-shadow: 0 2px 8px rgba(26,58,107,.25);
}
.btn-calculate:hover { background: var(--navy-light); box-shadow: 0 4px 14px rgba(26,58,107,.35); transform: translateY(-1px); }
.btn-calculate:active { transform: translateY(0); }
.btn-reset {
  padding: 12px 20px;
  background: #fff; color: var(--text-muted);
  font-size: .9rem; font-weight: 500;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  transition: background .15s, color .15s, border-color .15s;
}
.btn-reset:hover { background: #f8fafc; color: var(--text-body); border-color: #94a3b8; }

/* Result Box */
.result-box {
  margin-top: 22px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--green-border);
  overflow: hidden;
  animation: fadeUp .3s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.result-answer {
  background: var(--navy);
  color: #fff;
  padding: 20px 24px;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
}
.result-answer strong { color: #93c5fd; }
.steps-details { background: var(--green-bg); }
.steps-summary {
  padding: 11px 18px;
  font-size: .85rem; font-weight: 600;
  color: var(--green);
  cursor: pointer; list-style: none;
  border-top: 1px solid var(--green-border);
  transition: background .15s;
  user-select: none;
}
.steps-summary::-webkit-details-marker { display: none; }
details[open] .steps-summary { background: #dcfce7; }
.steps-body {
  padding: 16px 20px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.step-item { display: flex; gap: 12px; align-items: flex-start; }
.step-num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--navy); color: #fff;
  font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.step-text { font-size: .85rem; color: var(--text-body); line-height: 1.6; }
.step-text code {
  background: #e0e7ff; color: #1e3a8a;
  padding: 2px 6px; border-radius: 4px;
  font-size: .82em; font-family: 'Courier New', monospace;
}

/* Error Box */
.error-box {
  margin-top: 16px; padding: 13px 16px;
  background: var(--red-bg); border: 1.5px solid var(--red-border);
  border-radius: var(--radius); color: var(--red);
  font-size: .875rem; font-weight: 500;
  animation: fadeUp .25s ease;
}
.hidden { display: none !important; }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}
.sidebar-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: .875rem; font-weight: 700; color: var(--navy);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid var(--border);
}

/* Formula Triangle */
.formula-triangle-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.formula-svg { width: 160px; height: auto; display: block; }
.formula-legend {
  display: flex; flex-direction: column; gap: 4px; width: 100%;
}
.formula-legend div { font-size: .82rem; color: var(--text-body); }
.formula-legend strong { color: var(--navy); }

/* Formula List */
.formula-list {
  list-style: none;
  display: flex; flex-direction: column; gap: 10px;
}
.formula-list li {
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.formula-name { display: block; font-size: .75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.formula-code {
  display: block; font-family: 'Courier New', monospace;
  font-size: .82rem; color: var(--navy); font-weight: 700;
  background: var(--blue-light); padding: 4px 8px; border-radius: 4px;
}

/* Quick Examples */
.quick-examples { display: flex; flex-direction: column; gap: 6px; }
.qex-btn {
  width: 100%; text-align: left;
  padding: 9px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .82rem; color: var(--text-body);
  transition: background .15s, border-color .15s, color .15s;
}
.qex-btn:hover { background: var(--blue-light); border-color: #93c5fd; color: var(--navy); }

/* ── CONTENT SECTIONS ────────────────────────────────────────── */
.content-section { margin-top: 20px; }
.content-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}
.content-heading {
  font-size: 1.3rem; font-weight: 800; color: var(--text-main);
  margin-bottom: 8px;
}
.content-intro {
  font-size: .9rem; color: var(--text-muted);
  margin-bottom: 22px; line-height: 1.6;
}

/* Concept Grid */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.concept-item {
  padding: 18px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--input-bg);
  transition: border-color .15s, box-shadow .15s;
}
.concept-item:hover { border-color: #93c5fd; box-shadow: 0 2px 10px rgba(26,58,107,.1); }
.concept-num {
  font-size: 1.5rem; font-weight: 800; color: var(--navy);
  opacity: .25; line-height: 1; margin-bottom: 8px;
}
.concept-item h3 { font-size: .9rem; font-weight: 700; color: var(--text-main); margin-bottom: 8px; }
.concept-item p { font-size: .82rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 10px; }
.concept-formula {
  display: inline-block;
  font-family: 'Courier New', monospace; font-size: .78rem;
  background: var(--blue-light); color: var(--navy);
  padding: 4px 10px; border-radius: 4px; font-weight: 700;
}

/* Examples Table */
.examples-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.examples-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.examples-table th {
  background: var(--navy); color: #fff;
  padding: 11px 16px; text-align: left;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.examples-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  color: var(--text-body); vertical-align: middle;
}
.examples-table tr:last-child td { border-bottom: none; }
.examples-table tbody tr:hover td { background: #f0f4fa; }
.ex-tag {
  display: inline-block; padding: 2px 10px;
  background: var(--blue-light); color: var(--navy);
  font-size: .72rem; font-weight: 600; border-radius: 100px;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.ex-try-btn {
  padding: 6px 14px;
  background: var(--navy); color: #fff;
  font-size: .78rem; font-weight: 600;
  border: none; border-radius: var(--radius);
  transition: background .15s;
  white-space: nowrap;
}
.ex-try-btn:hover { background: var(--navy-light); }

/* Formula Reference Table */
.formula-ref-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.formula-ref-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.formula-ref-table th {
  background: var(--navy); color: #fff;
  padding: 11px 16px; text-align: left;
  font-size: .8rem; font-weight: 600;
}
.formula-ref-table td {
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  color: var(--text-body); vertical-align: top;
}
.formula-ref-table tr:last-child td { border-bottom: none; }
.formula-ref-table tr:hover td { background: #f0f4fa; }
.formula-ref-table code {
  background: var(--blue-light); color: var(--navy);
  padding: 3px 7px; border-radius: 4px;
  font-size: .82em; font-family: 'Courier New', monospace;
  font-weight: 700; white-space: nowrap;
}

/* FAQ */
.faq-list { display: flex; flex-direction: column; gap: 4px; max-width: 760px; }
.faq-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color .15s;
}
.faq-item[open] { border-color: #93c5fd; }
.faq-q {
  padding: 14px 16px; font-size: .9rem; font-weight: 600;
  color: var(--text-main); cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  transition: background .15s;
}
.faq-q::-webkit-details-marker { display: none; }
.faq-q::after { content: '+'; font-size: 1.2rem; font-weight: 300; color: var(--navy); flex-shrink: 0; transition: transform .15s; }
.faq-item[open] .faq-q::after { transform: rotate(45deg); }
.faq-q:hover { background: #f0f4fa; }
.faq-a { padding: 0 16px 16px; font-size: .875rem; color: var(--text-muted); line-height: 1.65; }
.faq-a em { font-style: italic; }
.faq-a strong { color: var(--text-body); }

/* ── FOOTER ──────────────────────────────────────────────────── */
.site-footer {
  background: var(--navy);
  padding: 36px 20px;
  margin-top: 40px;
}
.footer-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-logo-text { font-size: 1rem; font-weight: 700; color: #fff; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px; }
.footer-nav a { color: rgba(255,255,255,.6); font-size: .82rem; transition: color .15s; }
.footer-nav a:hover { color: #fff; text-decoration: none; }
.footer-copy { color: rgba(255,255,255,.35); font-size: .77rem; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main-cols { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}
@media (max-width: 640px) {
  .header-nav-bar nav { flex-wrap: wrap; }
  .header-nav-bar nav a { padding: 8px 12px; font-size: .82rem; }
  .logo-text { font-size: .9rem; }
  .calc-card { padding: 20px 16px; }
  .content-card { padding: 20px 16px; }
  .mode-tabs { gap: 2px; }
  .mode-tab { padding: 8px 12px; font-size: .8rem; }
  .calc-title { font-size: 1.25rem; }
  .calc-actions { flex-direction: column; }
  .btn-calculate, .btn-reset { width: 100%; }
  .sidebar { grid-template-columns: 1fr; }
  .concept-grid { grid-template-columns: 1fr 1fr; }
  .result-answer { font-size: 1rem; padding: 16px 16px; }
  .page-wrap { padding: 14px 12px 40px; }
}
@media (max-width: 420px) {
  .concept-grid { grid-template-columns: 1fr; }
}

/* ── PRINT ───────────────────────────────────────────────────── */
@media print {
  .site-header, .ad-banner, .sidebar, .calc-actions, .btn-add-row,
  .mode-tabs, .site-footer, .examples-table-wrap { display: none; }
  .main-cols { grid-template-columns: 1fr; }
  .result-answer { background: #eee; color: #000; }
}
