/* =============================================================
   STYLE.CSS  —  Marine Tools
   ============================================================= */

/* -------------------------------------------------------------
   1. DESIGN TOKENS
   ------------------------------------------------------------- */
:root {
  --bg:          #f4f7fb;
  --panel:       #ffffff;
  --text:        #0f1f33;
  --muted:       #546070;
  --brand:       #0369a1;
  --brand-dark:  #075985;
  --brand-light: #e0f2fe;
  --accent:      #0891b2;
  --border:      #d1dae8;
  --shadow-sm:   0 2px 8px rgba(15, 31, 51, 0.06);
  --shadow:      0 8px 32px rgba(15, 31, 51, 0.10);
  --shadow-lg:   0 20px 60px rgba(15, 31, 51, 0.13);
  --radius-sm:   10px;
  --radius:      16px;
  --radius-lg:   24px;
  --wind-bg:        #eff6ff;
  --wind-accent:    #2563eb;
  --wind-border:    #bfdbfe;
  --nav-bg:         #f0fdf4;
  --nav-accent:     #16a34a;
  --nav-border:     #bbf7d0;
  --elec-bg:        #fefce8;
  --elec-accent:    #ca8a04;
  --elec-border:    #fde68a;
  --fluid-bg:       #f0f9ff;
  --fluid-accent:   #0284c7;
  --fluid-border:   #bae6fd;
  --ref-bg:         #faf5ff;
  --ref-accent:     #7c3aed;
  --ref-border:     #ddd6fe;
  --tools-bg:       #fff7ed;
  --tools-accent:   #ea580c;
  --tools-border:   #fed7aa;
  --ok:        #16a34a;
  --warn:      #ca8a04;
  --danger:    #dc2626;
  --ok-bg:     #f0fdf4;
  --warn-bg:   #fefce8;
  --danger-bg: #fef2f2;
}

/* 2. RESET & BASE */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 1rem;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 0.6em; font-weight: 800; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.35rem); }
h4 { font-size: 1rem; }
p  { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

/* 3. LAYOUT */
.container {
  width: min(1140px, calc(100% - 32px));
  margin: 0 auto;
}
.section    { padding: 48px 0; }
.section-sm { padding: 28px 0; }
.two-col   { display: grid; grid-template-columns: 1fr 1fr;          gap: 24px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr);   gap: 20px; }

/* 4. HEADER & NAV */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 0;
}
.brand {
  font-weight: 900;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--brand-dark);
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.brand::before { content: '⚓ '; font-size: 1em; }
nav#main-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
nav#main-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}
nav#main-nav a:hover,
nav#main-nav a[aria-current="page"] { background: var(--brand-light); color: var(--brand-dark); }
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  margin-left: auto;
}
.nav-toggle span { display: block; height: 2px; background: var(--text); border-radius: 2px; transition: transform 0.2s; }

/* 5. HERO */
.hero {
  padding: 72px 0 56px;
  background:
    radial-gradient(ellipse at top left, #cce4f6 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, #d1fae5 0%, transparent 50%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}
.hero h1 { max-width: 760px; }
.hero-copy { font-size: 1.2rem; color: var(--muted); max-width: 600px; margin: 16px 0 32px; }
.eyebrow {
  display: inline-block;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

/* 6. CARDS & GRIDS */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.tool-card {
  display: block;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand); }
.tool-card-icon { font-size: 1.8rem; display: block; margin-bottom: 10px; }
.tool-card h3   { font-size: 1.05rem; margin-bottom: 6px; color: var(--text); }
.tool-card p    { font-size: 0.9rem; color: var(--muted); margin: 0; }

.section-card {
  display: block;
  padding: 28px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  border: 2px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}
.section-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.section-card .card-icon { font-size: 2.2rem; margin-bottom: 12px; display: block; }
.section-card h2 { font-size: 1.3rem; margin-bottom: 6px; }
.section-card p  { font-size: 0.92rem; margin: 0; }
.section-card.wind       { background: var(--wind-bg);  border-color: var(--wind-border);  color: var(--wind-accent);  }
.section-card.navigation { background: var(--nav-bg);   border-color: var(--nav-border);   color: var(--nav-accent);   }
.section-card.electrical { background: var(--elec-bg);  border-color: var(--elec-border);  color: var(--elec-accent);  }
.section-card.fluids     { background: var(--fluid-bg); border-color: var(--fluid-border); color: var(--fluid-accent); }
.section-card.reference  { background: var(--ref-bg);   border-color: var(--ref-border);   color: var(--ref-accent);   }
.section-card.tools      { background: var(--tools-bg); border-color: var(--tools-border); color: var(--tools-accent); }
.section-card h2, .section-card p { color: inherit; }

/* 7. PANELS */
.converter-panel, .calculator-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 760px;
}
.info-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-top: 20px;
}
.info-card h2, .info-card h3 { font-size: 1.1rem; margin-bottom: 10px; }
.quick-links {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.quick-links h2 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.quick-link-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.quick-link-row::-webkit-scrollbar { display: none; }
.quick-link-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.quick-link-button:hover { background: #bae6fd; border-color: var(--brand); }

/* 8. FORM ELEMENTS */
.converter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.converter-row.three { grid-template-columns: 1fr 1fr 1fr; }
label {
  display: block;
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input, select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 1.05rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.15);
}
select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23546070' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
input[readonly] {
  background: var(--brand-light);
  border-color: var(--brand-light);
  font-weight: 700;
  color: var(--brand-dark);
}
input::placeholder { color: #9eaab8; }

.result-box {
  background: var(--brand-light);
  border: 1.5px solid #7ec8e3;
  color: var(--brand-dark);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 16px;
  min-height: 52px;
}
.result-box.result-error      { background: var(--danger-bg); border-color: #fca5a5; color: var(--danger); }
.result-box.result-acceptable  { background: var(--ok-bg);     border-color: #86efac; color: var(--ok);     }
.result-box.result-marginal    { background: var(--warn-bg);   border-color: #fcd34d; color: var(--warn);   }
.result-box.result-critical    { background: var(--danger-bg); border-color: #fca5a5; color: var(--danger); }

button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
button.btn:hover, a.btn:hover { background: var(--brand-dark); }
button.btn-secondary {
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--border);
}
button.btn-secondary:hover { background: var(--brand-light); border-color: var(--brand); }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

/* 9. BEAUFORT PANEL */
.beaufort-panel {
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-top: 20px;
  transition: background 0.4s ease, color 0.4s ease;
  border: 2px solid transparent;
}
.bft-force { font-size: 2.5rem; font-weight: 900; line-height: 1; margin-bottom: 4px; }
.bft-desc  { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.bft-sea   { font-size: 0.95rem; opacity: 0.85; }

.bft-row-0  { background: #f0f9ff; }
.bft-row-1  { background: #e0f2fe; }
.bft-row-2  { background: #bae6fd; }
.bft-row-3  { background: #7dd3fc; }
.bft-row-4  { background: #38bdf8; color: #fff; }
.bft-row-5  { background: #0ea5e9; color: #fff; }
.bft-row-6  { background: #0284c7; color: #fff; }
.bft-row-7  { background: #0369a1; color: #fff; }
.bft-row-8  { background: #1e3a5f; color: #fff; }
.bft-row-9  { background: #7f1d1d; color: #fff; }
.bft-row-10 { background: #991b1b; color: #fff; }
.bft-row-11 { background: #b91c1c; color: #fff; }
.bft-row-12 { background: #dc2626; color: #fff; }

/* 10. TABLES */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 0.93rem; }
th {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
}
td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafd; }

td.vhf-emergency  { background: #fef2f2; color: #991b1b; font-weight: 700; }
td.vhf-coastguard { background: #eff6ff; color: #1e40af; font-weight: 600; }
td.vhf-dsc        { background: #fefce8; color: #92400e; font-weight: 600; }
td.vhf-marina     { background: #f0fdf4; color: #166534; }

.light-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.15);
}
.light-white  { background: #f9fafb; border-color: #d1d5db; }
.light-red    { background: #dc2626; }
.light-green  { background: #16a34a; }
.light-yellow { background: #ca8a04; }

/* 11. BATTERY LOAD ROWS */
.battery-load-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 10px;
  align-items: end;
}
.remove-load {
  padding: 13px 14px;
  background: #fef2f2;
  border: 1.5px solid #fca5a5;
  border-radius: var(--radius-sm);
  color: var(--danger);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background 0.15s;
}
.remove-load:hover { background: #fee2e2; }

/* 12. REFERENCE CARDS */
.mayday-steps {
  counter-reset: mayday-step;
  list-style: none;
  padding: 0;
  margin: 0;
}
.mayday-steps li {
  counter-increment: mayday-step;
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.mayday-steps li:last-child { border-bottom: none; }
.mayday-steps li::before {
  content: counter(mayday-step);
  min-width: 28px; height: 28px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.alert-card { border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px; }
.alert-card.danger { background: #fef2f2; border: 2px solid #fca5a5; color: #7f1d1d; }
.alert-card.info   { background: var(--brand-light); border: 2px solid #7ec8e3; color: var(--brand-dark); }

.phonetic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.phonetic-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
}
.phonetic-card .letter { font-size: 1.6rem; font-weight: 900; color: var(--brand); line-height: 1; }
.phonetic-card .word   { font-size: 0.95rem; font-weight: 700; margin-top: 4px; }
.phonetic-card .pron   { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.formula {
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  background: #0f1f33;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 0.95rem;
  overflow-x: auto;
  margin: 12px 0;
}

/* 13. FOOTER */
.site-footer {
  background: #0f1f33;
  color: #94a3b8;
  padding: 40px 0 28px;
  margin-top: 60px;
}
.footer-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 32px 48px;
  align-items: start;
}
.footer-brand .brand { color: #e2e8f0; font-size: 1.05rem; }
.footer-brand p { font-size: 0.88rem; margin-top: 6px; color: #64748b; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer-nav a { color: #94a3b8; text-decoration: none; font-size: 0.9rem; transition: color 0.15s; }
.footer-nav a:hover { color: #e2e8f0; }
.footer-note {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: #475569;
  border-top: 1px solid #1e3a5f;
  padding-top: 20px;
  margin: 0;
}

/* 14. UTILITIES */
.text-muted { color: var(--muted); }
.text-brand { color: var(--brand); }
.text-sm    { font-size: 0.88rem; }
.text-lg    { font-size: 1.15rem; }
.font-bold  { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* 15. RESPONSIVE */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  nav#main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px 16px;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow);
  }
  nav#main-nav.nav-open { display: flex; }
  .header-inner { position: relative; flex-wrap: wrap; }
  .hero { padding: 40px 0 32px; }
  .converter-row       { grid-template-columns: 1fr; }
  .converter-row.three { grid-template-columns: 1fr; }
  .two-col   { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
  .battery-load-row {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .battery-load-row .load-name { grid-column: 1 / -1; }
  .footer-inner { grid-template-columns: 1fr; gap: 20px; }
  .phonetic-grid { grid-template-columns: repeat(3, 1fr); }
  h1 { font-size: clamp(1.7rem, 7vw, 2.5rem); }
}

@media (max-width: 480px) {
  .tool-grid { grid-template-columns: 1fr; }
  .phonetic-grid { grid-template-columns: repeat(2, 1fr); }
  .converter-panel, .calculator-panel { padding: 18px; }
}

/* =============================================================
   16. MOBILE CALCULATOR UX
   Applies to all calculator/converter pages on narrow viewports.
   — Prevents iOS auto-zoom (font-size >= 16px on inputs)
   — Ensures 44px minimum touch targets on inputs, selects, buttons
   — Moves result box above notes/formula on mobile (result-first)
   ============================================================= */

/* 16a. Minimum font size on inputs — stops iOS zooming on focus */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px; /* hard minimum — do not use rem here */
  }
}

/* 16b. 44px minimum touch target height on all interactive form elements */
input, select, textarea,
button.btn, a.btn,
.remove-load,
.quick-link-button {
  min-height: 44px;
}

/* Buttons already have padding — just ensure they don't go below 44px */
button.btn, a.btn {
  padding-top: max(11px, calc((44px - 1.2em) / 2));
  padding-bottom: max(11px, calc((44px - 1.2em) / 2));
}

/* 16c. Result-first layout on mobile
   Wrap inputs + result in .calc-layout; on mobile the result floats up.
   Existing pages use .result-box directly — we use order to reflow. */
@media (max-width: 768px) {
  .calculator-panel,
  .converter-panel {
    display: flex;
    flex-direction: column;
  }

  /* Any .result-box inside a panel rises to the top on mobile */
  .calculator-panel .result-box,
  .converter-panel  .result-box {
    order: -1;
    margin-top: 0;
    margin-bottom: 20px;
  }

  /* Notes / formula / info sections stay below inputs */
  .calculator-panel .formula,
  .converter-panel  .formula,
  .calculator-panel .info-card,
  .converter-panel  .info-card {
    order: 99;
  }
}

/* 16d. Larger tap targets for the battery load remove button on mobile */
@media (max-width: 768px) {
  .remove-load {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* 16e. Extra breathing room in panels on very small screens */
@media (max-width: 380px) {
  .converter-panel, .calculator-panel {
    padding: 14px;
  }
  .converter-row {
    gap: 12px;
    margin-bottom: 14px;
  }
}
