/* =========================================================================
   Seafarer Rest Hours Calculator — shared design system
   Color tokens follow a validated light/dark categorical + status palette.
   ========================================================================= */

:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  --good:           #0ca30c;
  --good-text:      #006300;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;

  --series-work:    #2a78d6; /* blue */
  --series-rest:    #1baf7a; /* aqua */
  --series-accent:  #4a3aa7; /* violet */

  /* Header keeps a fixed nautical navy in both themes — it's brand
     chrome, not a surface that should flip with light/dark mode. */
  --header-bg:        #0e2a43;
  --header-bg-hover:  #16405f;
  --header-text:      #f3f6f8;
  --header-text-dim:  #a9c0d1;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --maxw: 960px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);

    --good:           #0ca30c;
    --good-text:      #0ca30c;
    --warning:        #fab219;
    --serious:        #ec835a;
    --critical:       #e66767;

    --series-work:    #3987e5;
    --series-rest:    #199e70;
    --series-accent:  #9085e9;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page-plane:     #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);

  --good:           #0ca30c;
  --good-text:      #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #e66767;

  --series-work:    #3987e5;
  --series-rest:    #199e70;
  --series-accent:  #9085e9;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
  line-height: 1.55;
}

a { color: var(--series-work); }
a:hover { text-decoration: none; }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------------------------------------------------
   Header / nav
   --------------------------------------------------------------------- */

header.site-header {
  border-bottom: 1px solid var(--header-bg-hover);
  background: var(--header-bg);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--header-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--series-rest); display: inline-block; }

nav.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

nav.site-nav a {
  color: var(--header-text-dim);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
nav.site-nav a:hover { background: var(--header-bg-hover); color: var(--header-text); }
nav.site-nav a[aria-current="page"] {
  color: var(--header-bg);
  background: var(--header-text);
  font-weight: 600;
}

/* ---------------------------------------------------------------------
   Hero / page intro
   --------------------------------------------------------------------- */

.hero {
  padding: 36px 0 8px;
}
.hero h1 {
  font-size: clamp(1.6rem, 3.2vw, 2.3rem);
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.hero p.lede {
  color: var(--text-secondary);
  max-width: 62ch;
  font-size: 1.05rem;
}
.hero.center {
  text-align: center;
}
.hero.center p.lede {
  margin-left: auto;
  margin-right: auto;
}

main { padding-bottom: 56px; }

.prose { max-width: 74ch; }
.prose h2 { margin-top: 2.2em; font-size: 1.35rem; }
.prose h3 { margin-top: 1.6em; font-size: 1.1rem; }
.prose p, .prose li { color: var(--text-primary); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose table { border-collapse: collapse; width: 100%; margin: 1.2em 0; }
@media (max-width: 620px) {
  .prose table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
}
.prose th, .prose td { border: 1px solid var(--gridline); padding: 8px 10px; text-align: left; font-size: 0.94rem; }
.prose th { background: var(--surface-1); }

/* ---------------------------------------------------------------------
   Cards / panels
   --------------------------------------------------------------------- */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.card + .card { margin-top: 18px; }

.panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 4px;
}
.panel-sub { color: var(--text-secondary); font-size: 0.92rem; margin: 0 0 18px; }

/* ---------------------------------------------------------------------
   Tabs (rest-periods mode vs weekly-schedule simulator)
   --------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--gridline);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 10px 4px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab-btn + .tab-btn { margin-left: 18px; }
.tab-btn:hover { color: var(--text-primary); }
.tab-btn[aria-selected="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--series-work);
}
.tab-panel[hidden] { display: none; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.window-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 620px) {
  .field-row, .window-row { grid-template-columns: 1fr; }
}

label { font-size: 0.84rem; color: var(--text-secondary); display: block; margin-bottom: 4px; }

input[type="datetime-local"],
select {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--baseline);
  background: var(--page-plane);
  color: var(--text-primary);
}
input[type="datetime-local"]:focus, select:focus {
  outline: 2px solid var(--series-work);
  outline-offset: 1px;
}

fieldset {
  border: 1px solid var(--gridline);
  border-radius: var(--radius-md);
  padding: 14px 16px 16px;
  margin: 0 0 16px;
}
legend { font-weight: 700; font-size: 0.9rem; padding: 0 6px; }

.radio-row { display: flex; gap: 18px; flex-wrap: wrap; }
.radio-opt { display: flex; align-items: flex-start; gap: 8px; font-size: 0.92rem; max-width: 320px; }
.radio-opt input { margin-top: 3px; }
.radio-opt .opt-desc { color: var(--text-secondary); font-size: 0.82rem; }

button, .btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
}
button:hover { background: var(--gridline); }

.btn-remove {
  border-color: transparent;
  background: transparent;
  color: var(--critical);
  padding: 8px 10px;
}
.btn-remove:hover { background: var(--gridline); }

.btn-primary {
  background: var(--series-work);
  border-color: var(--series-work);
  color: #fff;
  padding: 11px 20px;
  font-size: 0.95rem;
}
.btn-primary:hover { filter: brightness(1.08); background: var(--series-work); }

.btn-add {
  background: transparent;
  border-style: dashed;
  color: var(--text-secondary);
}

.actions-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }

.day-block {
  border: 1px solid var(--gridline);
  border-radius: var(--radius-md);
  padding: 12px 14px 14px;
  margin-bottom: 12px;
}
.day-block > .day-label { font-weight: 700; font-size: 0.9rem; margin-bottom: 8px; }

/* ---------------------------------------------------------------------
   Results
   --------------------------------------------------------------------- */

.summary-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  margin-bottom: 18px;
  font-size: 1.02rem;
}
.summary-banner.ok { background: color-mix(in srgb, var(--good) 14%, var(--surface-1)); color: var(--good-text); }
.summary-banner.bad { background: color-mix(in srgb, var(--critical) 14%, var(--surface-1)); color: var(--critical); }
.summary-banner .icon { font-size: 1.3rem; }

.rule-list { list-style: none; margin: 0; padding: 0; }
.rule-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-top: 1px solid var(--gridline);
}
.rule-item:first-child { border-top: none; }
.rule-status {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  margin-top: 2px;
}
.rule-status.pass { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good-text); }
.rule-status.fail { background: color-mix(in srgb, var(--critical) 22%, transparent); color: var(--critical); }
.rule-body strong { display: block; font-size: 0.95rem; }
.rule-detail { color: var(--text-secondary); font-size: 0.87rem; margin-top: 2px; }
.rule-detail .viol { color: var(--critical); }

.warn-note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--warning) 16%, var(--surface-1));
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 12px;
}

/* ---------------------------------------------------------------------
   Timeline chart
   --------------------------------------------------------------------- */

.timeline-wrap { margin-top: 8px; }

.timeline-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.legend-chip { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.timeline-scale {
  display: grid;
  grid-template-columns: 74px 1fr;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.timeline-scale .ticks { display: flex; justify-content: space-between; }

.timeline-day {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.timeline-day .day-tag {
  font-size: 0.74rem;
  color: var(--text-secondary);
  text-align: right;
  padding-right: 6px;
}
.timeline-track-wrap { display: flex; flex-direction: column; gap: 3px; }
.timeline-track {
  position: relative;
  height: 26px;
  background: var(--gridline);
  border-radius: 5px;
  overflow: hidden;
}
.timeline-seg {
  position: absolute;
  top: 0; bottom: 0;
  border-right: 2px solid var(--surface-1);
}
.timeline-seg.rest { background: var(--series-rest); }
.timeline-seg.work { background: var(--series-work); }
/* Violations get their own slim strip below the rest/work track, in
   solid red, rather than an overlay on top of the track. Overlapping
   a translucent marker on colored segments would shift hue wherever
   rest, work, and a violation window all coincide — reading as a
   different (and confusing) color rather than "problem here." A
   separate strip keeps the rest/work colors pure and the violation
   marker unambiguous regardless of what's underneath it. */
.timeline-viol-strip {
  position: relative;
  height: 7px;
  background: var(--gridline);
  border-radius: 3px;
  overflow: hidden;
}
.timeline-viol {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--critical);
}

/* ---------------------------------------------------------------------
   Ad slots — placeholders until an AdSense publisher ID is approved
   --------------------------------------------------------------------- */

.ad-slot {
  margin: 28px 0;
  padding: 14px;
  border: 1px dashed var(--baseline);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------- */

footer.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 40px;
  color: var(--text-muted);
  font-size: 0.82rem;
}
footer.site-footer a { color: var(--text-secondary); }
footer.site-footer nav { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }

.callout {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 4px solid var(--series-accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 1.4em 0;
  font-size: 0.94rem;
}
.callout.legal { border-left-color: var(--warning); }

.faq-item { border-bottom: 1px solid var(--gridline); padding: 16px 0; }
.faq-item h3 { margin: 0 0 6px; font-size: 1rem; }
.faq-item p { margin: 0; color: var(--text-secondary); }
