@import "tailwindcss";
@import "intl-tel-input/styles-no-assets";

@theme {
  --color-canvas: #FFFCF7;
  --color-surface: #FFFFFF;
  --color-ink: #1B2333;
  --color-ink-soft: #3A3F4B;
  --color-muted: #4B5263;
  --color-accent: #1E3FB8;
  --color-accent-hover: #152E87;
  --color-accent-soft: #EDF1FD;
  --color-border: #E6DED0;
  --color-kraft: #E9DCC6;
  --color-kraft-soft: #F7F2E9;
  --color-kraft-line: #D4C09A;
  --color-kraft-text: #5C4A35;
  /* Page tones: each landing page tints its hero so it reads apart from the kraft homepage. */
  --color-sky: #DDE5F8;
  --color-sage: #D9E6DA;
  --color-sage-soft: #EEF4EE;
  --color-sage-line: #B5CCB8;
  --color-sage-deep: #5F8F67;
  --color-slate: #1E293B;
  --color-slate-raised: #2A3850;
  --color-slate-line: #3E4C63;
  --color-slate-text: #CBD5E1;
  --color-wheat: #E9C58F;
  --color-notice-bg: #FFF5DB;
  --color-notice-text: #705000;
  --color-error: #B42318;
  --color-success: #006300;
  --color-rise: #A3442B;
  --color-fall: #147568;
  --font-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "DM Sans", ui-sans-serif, system-ui, sans-serif;
}

/* Chart series, validated for color-vision deficiency in this order on the white card surface.
   Static, because charts reference them as CSS variables rather than utility classes. */
@theme static {
  --color-series-1: #2A78D6;
  --color-series-2: #EB6834;
  --color-series-3: #1BAF7A;
  --color-series-4: #EDA100;
  --color-series-5: #E87BA4;
  --color-chart-muted: #898781;
}

@layer base {
  html { -webkit-text-size-adjust: 100%; }
  body { @apply bg-canvas text-ink font-sans text-lg leading-[1.65] antialiased; }
  h1, h2, h3 { @apply font-display text-balance; }
  h1 { @apply text-[2.375rem] md:text-[3.5rem] font-extrabold leading-[1.05] tracking-[-0.02em]; }
  h2 { @apply text-[1.875rem] md:text-[2.75rem] font-extrabold leading-[1.1] tracking-[-0.01em]; }
  h3 { @apply text-xl md:text-2xl font-bold leading-snug; }
  p, li { @apply text-pretty; }
  a { @apply text-accent underline-offset-2 hover:text-accent-hover; }
  :focus-visible { @apply outline-3 outline-offset-2 outline-accent; }
  table { font-variant-numeric: tabular-nums; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  }
}

@layer components {
  .container-page { @apply mx-auto w-full max-w-[1200px] px-5 md:px-6; }
  .section { @apply py-14 md:py-24; }
  .reading { @apply max-w-[740px]; }
  .eyebrow { @apply mb-3 text-base font-semibold text-accent; }
  .lede { @apply text-ink-soft text-lg md:text-xl; }
  .meta { @apply text-sm text-muted; }
  .card { @apply rounded-[20px] border border-border bg-surface p-6 md:p-8; }
  .example { @apply rounded-[14px] bg-kraft-soft p-4 md:px-5 text-base; }
  .example-label { @apply mb-2.5 text-[13px] font-semibold uppercase tracking-wider text-kraft-text; }
  .btn-primary { @apply inline-flex min-h-12 items-center justify-center rounded-xl bg-accent px-6 font-semibold text-white no-underline hover:bg-accent-hover hover:text-white disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-accent; }
  .btn-secondary { @apply inline-flex min-h-12 items-center justify-center rounded-xl border border-border bg-surface px-5 font-semibold text-ink no-underline hover:bg-kraft-soft hover:text-ink disabled:cursor-not-allowed disabled:text-muted disabled:opacity-60 disabled:hover:bg-surface; }
  .chip { @apply inline-flex min-h-11 items-center rounded-full bg-canvas px-4 text-base font-semibold text-ink no-underline hover:bg-surface hover:text-ink; }
  /* Header dropdowns: the account menu and the signed-out site menu. */
  .menu-panel { @apply absolute right-0 z-40 mt-2 max-h-[calc(100dvh-6rem)] w-60 overflow-y-auto rounded-xl border border-border bg-surface py-2 text-[15px] shadow-lg; }
  .menu-section { @apply mt-1 border-t border-border pt-1; }
  .menu-label { @apply px-4 pt-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted; }
  .menu-link { @apply block w-full px-4 py-2 text-left text-ink no-underline hover:bg-accent-soft hover:text-ink; }
  .menu-link[aria-current="page"] { @apply font-semibold text-accent hover:text-accent; }
  .icon-tile { @apply flex size-13 flex-none items-center justify-center rounded-[14px] bg-kraft-soft text-accent; }
  .field-label { @apply mb-2 block text-base font-semibold; }
  .field-hint { @apply mt-1.5 block text-[15px] text-muted; }
  .field-input { @apply block min-h-13 w-full rounded-xl border border-[#C9C2B4] bg-surface px-3.5 text-base text-ink; }
  .field-error { @apply mt-1.5 block text-[15px] text-error; }
  .field-input[aria-invalid=true] { @apply border-error; }
  /* Flashes an email fixed by email_check_controller.js so the change is noticed. */
  .field-corrected { animation: field-corrected 1.6s ease-out; }
  .notice { @apply rounded-xl bg-notice-bg px-4 py-3 text-notice-text; }
  .toasts { @apply pointer-events-none fixed inset-x-0 top-4 z-40 flex flex-col items-center gap-2 px-4; }
  .toast { @apply pointer-events-auto flex w-full max-w-lg items-start gap-3 rounded-xl border border-[#F3E3B6] bg-notice-bg py-3 pr-2 pl-4 text-notice-text shadow-lg transition-opacity duration-200 motion-reduce:transition-none; }
  .toast[role=alert] { @apply border-[#F5C2BD] bg-[#FEF3F2] text-error; }
  .toast-leaving { @apply opacity-0; }
  .toast-close { @apply -my-1 ml-auto flex size-8 flex-none cursor-pointer items-center justify-center rounded-lg opacity-70 hover:bg-black/5 hover:opacity-100; }
  .panel-soft { @apply rounded-[20px] bg-kraft p-6 md:px-10 md:py-9; }
  .result-panel { @apply rounded-[20px] bg-slate p-6 text-white md:p-8; }
  .result-label { @apply text-sm font-semibold text-muted; }
  .result-figure { @apply mt-1 font-display text-[2.75rem] leading-none font-extrabold tabular-nums; }
  /* Tool cards share rows through a subgrid, so side-by-side cards line up their inputs, results, and links. */
  .tool-cards { @apply grid gap-6 lg:grid-cols-2; }
  .tool-card { @apply row-span-4 grid grid-rows-subgrid gap-y-0 overflow-hidden rounded-[20px] border border-border bg-surface; }
  .tool-card-title { @apply text-xl md:text-[1.375rem]; }
  .tool-card-form { @apply flex flex-wrap content-start items-end gap-x-6 gap-y-4 px-6 pt-6 md:px-8; }
  .tool-card-result { @apply mx-6 mt-6 block border-t border-border pt-5 md:mx-8; }
  .tool-card-footer { @apply self-end px-6 pt-5 pb-7 md:px-8; }
  .tool-card-link { @apply cursor-pointer text-left text-base font-semibold text-accent no-underline after:ml-1 after:content-['→'] hover:text-accent-hover hover:underline; }
  .tool-band { @apply flex items-center gap-3.5 border-b px-6 py-5 md:px-8; }
  .tool-band-icon { @apply flex size-11.5 flex-none items-center justify-center rounded-xl bg-surface; }
  .tool-band-dim { @apply border-[#D7E0FA] bg-accent-soft; }
  .tool-band-dim .tool-band-icon, .tool-tab-dim .tool-tab-icon { @apply text-accent; }
  .tool-band-fuel { @apply border-[#F3E3B6] bg-notice-bg; }
  .tool-band-fuel .tool-band-icon, .tool-tab-fuel .tool-tab-icon { @apply text-notice-text; }

  /* A tool's own page: tabs over one panel, inputs beside results. */
  .tool-tabs { @apply grid grid-cols-2 gap-1.5 sm:flex; }
  .tool-tab { @apply flex min-w-0 items-center gap-2.5 rounded-t-[14px] border border-b-0 border-border bg-kraft-soft px-3 py-2.5 text-[15px] font-semibold text-muted no-underline hover:text-ink sm:px-4.5 sm:text-[17px]; }
  .tool-tab[aria-current] { @apply relative z-[1] -mb-px pb-[11px] text-ink; }
  .tool-tab-dim[aria-current] { @apply bg-accent-soft; }
  .tool-tab-fuel[aria-current] { @apply bg-notice-bg; }
  .tool-tab-icon { @apply hidden flex-none sm:block; }
  .tool-panel { @apply grid rounded-[20px] border border-border bg-surface lg:grid-cols-[minmax(0,1.4fr)_minmax(0,1fr)]; }
  .tool-panel-dim { @apply rounded-tl-none; }
  .tool-panel-fuel { @apply max-sm:rounded-tr-none; }
  .tool-panel-main { @apply min-w-0 p-6 md:p-8; }
  .mode-tab { @apply inline-flex min-h-10 cursor-pointer items-center rounded-lg border border-border bg-surface px-3.5 text-[15px] font-semibold text-muted no-underline hover:text-ink aria-[current]:border-accent aria-[current]:bg-accent-soft aria-[current]:text-accent; }
  .tool-panel-side { @apply min-w-0 border-t border-[#F1EBE0] p-6 md:p-8 lg:border-t-0 lg:border-l; }
  .badge-upcoming { @apply inline-block rounded-md px-2 py-0.5 text-sm font-semibold bg-notice-bg text-notice-text; }
  .badge-current { @apply inline-block rounded-md px-2 py-0.5 text-sm font-semibold bg-accent-soft text-accent; }
  .badge-ended { @apply inline-block rounded-md px-2 py-0.5 text-sm font-semibold bg-kraft-soft text-muted; }
  .badge-success { @apply inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-sm font-semibold bg-sage-soft text-success; }
  /* A tag that's also the way to do something, e.g. "Enable autopilot". */
  .badge-action { @apply inline-flex items-center gap-1 rounded-md border border-accent px-2 py-px text-sm font-semibold text-accent no-underline hover:bg-accent-soft; }
  /* A row on its way out of a filtered list; see row_exit_controller.js. */
  .row-leaving { @apply opacity-0 transition-opacity duration-200 motion-reduce:transition-none; }
  .table-wrap { @apply overflow-x-auto rounded-2xl border border-border bg-surface; }
  .data-table { @apply w-full border-collapse text-base; }
  .data-table th { @apply border-b border-border px-3 py-3.5 text-left text-sm font-semibold whitespace-nowrap text-muted md:px-5; }
  .data-table td { @apply border-b border-[#F1EBE0] px-3 py-3.5 align-top md:px-5; }
  .data-table tbody th { @apply border-[#F1EBE0]; }
  .data-table tbody tr:last-child :is(td, th) { @apply border-b-0; }
  .data-table tbody + tbody tr:first-child :is(td, th) { @apply border-t border-t-[#F1EBE0]; }
  .data-table .num { @apply text-right tabular-nums; }
  .data-table-compact { @apply text-[15px]; }
  .data-table-compact :is(td, th) { @apply py-2.5; }
  .data-table-compact tbody th { @apply text-[15px]; }
  /* Below lg a stacking table turns each row into a block, labeling every cell from its
     data-label, so wide tables fit the screen instead of scrolling sideways. */
  .data-table-stack, .data-table-stack tbody, .data-table-stack tr { @apply max-lg:block; }
  .data-table-stack thead { @apply max-lg:sr-only; }
  .data-table-stack tr { @apply max-lg:border-b max-lg:border-border max-lg:px-4 max-lg:py-3; }
  .data-table-stack tr:last-child { @apply max-lg:border-b-0; }
  .data-table-stack tbody + tbody tr:first-child { @apply max-lg:border-t max-lg:border-border; }
  .data-table-stack :is(td, th), .data-table-stack .num { @apply max-lg:flow-root max-lg:border-0 max-lg:px-0 max-lg:py-1 max-lg:text-left max-lg:wrap-break-word; }
  .data-table-stack tbody th { @apply max-lg:text-base max-lg:whitespace-normal max-lg:text-ink; }
  .data-table-stack td:empty { @apply max-lg:hidden; }
  .data-table-stack td[data-label] { @apply max-lg:pl-32; }
  .data-table-stack td[data-label]::before { @apply max-lg:float-left max-lg:-ml-32 max-lg:w-28 max-lg:font-sans max-lg:text-sm max-lg:leading-[1.65] max-lg:font-semibold max-lg:text-muted max-lg:content-[attr(data-label)]; }
  /* The narrowest phones can't spare a label column, so labels sit above their values. */
  .data-table-stack td[data-label] { @apply max-[24rem]:pl-0; }
  .data-table-stack td[data-label]::before { @apply max-[24rem]:float-none max-[24rem]:ml-0 max-[24rem]:block max-[24rem]:w-auto; }
  .pagy.info { @apply text-[15px] text-muted; }
  .pagy.series-nav { @apply flex flex-wrap gap-1 text-[15px] font-semibold; }
  .pagy.series-nav a { @apply min-w-10 rounded-lg px-3 py-1.5 text-center text-ink no-underline; }
  .pagy.series-nav a[href]:hover { @apply bg-kraft-soft text-ink; }
  .pagy.series-nav a[aria-current] { @apply bg-accent text-surface; }
  .pagy.series-nav a[role="link"]:not([aria-current]) { @apply text-muted opacity-60; }
  .prose-guide { @apply text-lg leading-[1.65]; }
  .prose-guide h2 { @apply mt-12 mb-4 text-[1.75rem] md:text-[2.125rem]; }
  .prose-guide h3 { @apply mt-8 mb-3; }
  .prose-guide p, .prose-guide ul, .prose-guide ol { @apply mb-5; }
  .prose-guide ul { @apply list-disc pl-6; }
  .prose-guide ol { @apply list-decimal pl-6; }
  .prose-guide li { @apply mb-2; }
  .prose-guide .example > :last-child { @apply mb-0; }
}

/* Signed-in app: the public palette at an application scale. */
@layer components {
  .app { @apply text-base; }
  .app h2 { @apply text-xl leading-snug; }
  .app .lede { @apply text-base; }
  .app .card { @apply rounded-xl p-5 md:p-6; }
  .app .btn-primary, .app .btn-secondary { @apply min-h-10 rounded-lg px-4 text-[15px]; }
  .app .field-input { @apply min-h-11 rounded-lg; }
  .app .field-label { @apply text-[15px]; }
  .app .notice, .app .toast { @apply text-[15px]; }
  .settings-list { @apply divide-y divide-border rounded-xl border border-border bg-surface px-5 md:px-6; }
  .settings-row { @apply flex flex-wrap items-center justify-between gap-x-6 gap-y-3 py-5; }
  .settings-row h3 { @apply font-sans text-base font-semibold; }
  .settings-row p { @apply text-sm text-muted; }

  /* Charts: hairline grid, thin marks, and a tooltip that repeats what the table view shows. */
  .chart-grid { @apply absolute inset-x-0 border-t border-[#F1EBE0]; }
  .chart-tick { @apply absolute right-2 translate-y-1/2 text-xs whitespace-nowrap text-muted tabular-nums; }
  .chart-band { @apply relative flex h-full flex-1 flex-col items-center outline-none hover:opacity-85 focus-visible:opacity-85; }
  .chart-crosshair { @apply hover:opacity-100 focus-visible:opacity-100; }
  .chart-crosshair:hover::after, .chart-crosshair:focus-visible::after { @apply absolute inset-y-0 left-1/2 border-l border-kraft-line content-['']; }
  .chart-line { @apply fill-none stroke-current; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
  .chart-dot { @apply pointer-events-none absolute size-2.5 -translate-x-1/2 -translate-y-1/2 rounded-full ring-2 ring-surface; }
  .chart-tip { @apply pointer-events-none absolute z-10 min-w-40 rounded-lg border border-border bg-surface px-3 py-2 text-sm shadow-lg; }
}

/* Unlayered so page titles stay at app size whatever utilities a shared partial adds. */
.app h1 { @apply text-[1.75rem] md:text-[2rem] leading-tight tracking-[-0.01em]; }

/* Turbo view transitions between the tool cards and each tool's page. Matching names morph a card's
   header into its tab and the card into the panel; snapshots keep their size so text doesn't stretch. */
.tool-band-dim, .tool-tab-dim { view-transition-name: tool-dim-head; }
.tool-band-fuel, .tool-tab-fuel { view-transition-name: tool-fuel-head; }
.tool-card:has(.tool-band-dim), .tool-panel-dim { view-transition-name: tool-dim; }
.tool-card:has(.tool-band-fuel), .tool-panel-fuel { view-transition-name: tool-fuel; }
::view-transition-group(*) { animation-duration: 0.35s; animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1); }
::view-transition-old(*), ::view-transition-new(*) { height: 100%; object-fit: none; object-position: left top; }
/* The rest of the page swaps quickly so old and new headings don't overlap while the tool morphs. */
::view-transition-old(root) { animation: 120ms ease-out both tool-fade-out; }
::view-transition-new(root) { animation: 200ms ease-out 80ms both tool-fade-in; }
@keyframes tool-fade-out { to { opacity: 0; } }
@keyframes tool-fade-in { from { opacity: 0; } }
@keyframes field-corrected {
  0%, 30% { background-color: var(--color-notice-bg); border-color: var(--color-wheat); box-shadow: 0 0 0 3px var(--color-notice-bg); }
}
