/* Picoballoon Float Calculator — sky & clouds theme */

:root {
  --sky-top: #5fb3e8;
  --sky-mid: #87ceeb;      /* skyblue */
  --sky-low: #d8f0fb;
  --cloud: rgba(255, 255, 255, 0.92);
  --card: rgba(255, 255, 255, 0.86);
  --card-border: rgba(255, 255, 255, 0.95);
  --ink: #17344d;
  --ink-soft: #4b6b84;
  --accent: #1f78b4;
  --accent-soft: #e3f2fc;
  --on-accent: #ffffff;
  --balloon: #f2b134;
  --balloon-shade: #e08e1b;
  --low: #ffd9b3;
  --nofit: #e9edf1;
  --grid: rgba(23, 52, 77, 0.12);
  --bad: #c62828;
  --option-bg: #ffffff;
  color-scheme: light;   /* native controls (open dropdown lists, scrollbars) match the theme */
  --shadow: 0 10px 30px rgba(31, 92, 140, 0.18);
  --s1: #1f78b4; --s2: #2ca58d; --s3: #e08e1b; --s4: #c2410c; --s5: #7c3aed; --s6: #475569;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky-top: #0b1f3a; --sky-mid: #173a63; --sky-low: #2c5784;
    --cloud: rgba(200, 220, 240, 0.16);
    --card: rgba(16, 36, 62, 0.86); --card-border: rgba(140, 180, 220, 0.25);
    --ink: #e6f1fb; --ink-soft: #a9c3da; --accent: #7cc4f5; --accent-soft: rgba(124, 196, 245, 0.12); --on-accent: #0b1f3a;
    --low: #6b3d17; --nofit: #24364d; --grid: rgba(230, 241, 251, 0.14);
    --bad: #ff8a80;
    --option-bg: #10243e;
    color-scheme: dark;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --s1: #7cc4f5; --s2: #5fd3b5; --s3: #f6c25b; --s4: #f28b6b; --s5: #b9a2ff; --s6: #c8d3df;
  }
}
:root[data-theme="dark"] {
  --sky-top: #0b1f3a; --sky-mid: #173a63; --sky-low: #2c5784;
  --cloud: rgba(200, 220, 240, 0.16);
  --card: rgba(16, 36, 62, 0.86); --card-border: rgba(140, 180, 220, 0.25);
  --ink: #e6f1fb; --ink-soft: #a9c3da; --accent: #7cc4f5; --accent-soft: rgba(124, 196, 245, 0.12); --on-accent: #0b1f3a;
  --low: #6b3d17; --nofit: #24364d; --grid: rgba(230, 241, 251, 0.14);
  --bad: #ff8a80;
  --option-bg: #10243e;
  color-scheme: dark;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --s1: #7cc4f5; --s2: #5fd3b5; --s3: #f6c25b; --s4: #f28b6b; --s5: #b9a2ff; --s6: #c8d3df;
}

* { box-sizing: border-box; }

html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--sky-low);
  line-height: 1.5;
}

/* Sky backdrop with drifting clouds */
.sky {
  position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-low) 100%);
}
.cloud {
  position: absolute; display: block; background: var(--cloud); border-radius: 999px;
  filter: blur(1px); animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; background: inherit; border-radius: 50%;
}
.cloud::before { width: 55%; height: 160%; left: 14%; bottom: 30%; }
.cloud::after  { width: 40%; height: 130%; right: 14%; bottom: 25%; }
.c1 { width: 220px; height: 56px; top: 9%;  left: -260px; animation-duration: 90s; }
.c2 { width: 160px; height: 42px; top: 28%; left: -200px; animation-duration: 120s; animation-delay: -40s; opacity: .8; }
.c3 { width: 280px; height: 70px; top: 58%; left: -320px; animation-duration: 150s; animation-delay: -90s; opacity: .7; }
.c4 { width: 180px; height: 46px; top: 80%; left: -220px; animation-duration: 110s; animation-delay: -20s; opacity: .85; }
@keyframes drift { to { transform: translateX(calc(100vw + 400px)); } }
@media (prefers-reduced-motion: reduce) { .cloud { animation: none; left: 10%; } .c2 { left: 60%; } .c3 { left: 30%; } .c4 { left: 75%; } }

/* Link back to the main site, under the subtitle */
.back-link {
  margin-top: 8px;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px 4px 8px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; text-decoration: none;
  color: var(--ink); background: var(--card); border: 1px solid var(--card-border);
  box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.back-link:hover { color: var(--accent); }
.back-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.back-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.hero {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 18px;
  max-width: 1200px; margin: 0 auto; padding: 28px 16px 8px;
}
.balloon { width: 58px; height: 88px; flex: none; animation: bob 6s ease-in-out infinite; }
.balloon .envelope { fill: var(--balloon); stroke: var(--balloon-shade); stroke-width: 2; }
.balloon .knot { fill: var(--balloon-shade); }
.balloon .tether { fill: none; stroke: var(--ink-soft); stroke-width: 1.5; }
.balloon .payload { fill: var(--accent); }
@keyframes bob { 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .balloon { animation: none; } }

h1 { margin: 0; font-size: clamp(1.5rem, 3.5vw, 2.2rem); letter-spacing: .01em; color: #fff; text-shadow: 0 2px 8px rgba(23, 52, 77, .35); }
.sub { margin: 4px 0 0; color: #fff; opacity: .92; text-shadow: 0 1px 4px rgba(23, 52, 77, .35); }

/* Layout */
main {
  position: relative; z-index: 1;
  max-width: 1200px; margin: 0 auto; padding: 16px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px;
}
.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 22px; padding: 20px 22px; box-shadow: var(--shadow);
  backdrop-filter: blur(6px); min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
h2 { margin: 0 0 14px; font-size: 1.15rem; color: var(--accent); }
h2 small { font-weight: 400; color: var(--ink-soft); }

/* Form */
.grid-form { display: grid; grid-template-columns: 1fr 170px; gap: 10px 14px; align-items: center; }
label { color: var(--ink); font-size: .95rem; }
input, select {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--ink);
  background: var(--accent-soft); border: 1.5px solid transparent; border-radius: 12px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input.invalid, input.invalid:focus { border-color: var(--bad); }
select:disabled { opacity: .5; cursor: not-allowed; }
option { color: var(--ink); background-color: var(--option-bg); }
.derived { margin-top: 16px; border-top: 1px dashed var(--grid); padding-top: 12px; display: grid; gap: 6px; }
.derived div { display: flex; justify-content: space-between; gap: 12px; }
.derived .k { color: var(--ink-soft); }
.derived .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.hint { margin: 14px 0 0; font-size: .85rem; color: var(--ink-soft); }

/* Chart */
.chart svg { width: 100%; height: auto; display: block; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--ink-soft); stroke-width: 1; }
.chart .tick { fill: var(--ink-soft); font-size: 12px; }
.chart .axis-title { fill: var(--ink); font-size: 13px; font-weight: 600; }
.chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .label { font-size: 12px; font-weight: 600; }
.s1 { stroke: var(--s1); fill: var(--s1); } .s2 { stroke: var(--s2); fill: var(--s2); }
.s3 { stroke: var(--s3); fill: var(--s3); } .s4 { stroke: var(--s4); fill: var(--s4); }
.s5 { stroke: var(--s5); fill: var(--s5); } .s6 { stroke: var(--s6); fill: var(--s6); }
.chart .line.s1, .chart .line.s2, .chart .line.s3, .chart .line.s4, .chart .line.s5, .chart .line.s6 { fill: none; }
.chart .label { stroke: none; }
.empty { color: var(--ink-soft); }

/* Table */
.legend { margin: 0 0 12px; font-size: .88rem; color: var(--ink-soft); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; }
.swatch.low { background: var(--low); }
.table-wrap { overflow-x: auto; border-radius: 14px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .85rem; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
thead th { position: sticky; top: 0; background: var(--accent); color: var(--on-accent); text-align: center; font-weight: 600; }
tbody th { position: sticky; left: 0; background: var(--accent-soft); color: var(--ink); text-align: center; backdrop-filter: blur(6px); }
th.corner { text-align: left; font-size: .75rem; line-height: 1.25; left: 0; z-index: 2; }
tbody tr:hover td { background: var(--accent-soft); }
td.low { background: var(--low); }
td.nofit { background: var(--nofit); color: var(--ink-soft); text-align: center; font-style: italic; }

.notes p { margin: 0; color: var(--ink-soft); }

@media (max-width: 520px) {
  .grid-form { grid-template-columns: 1fr 150px; }
  .card { padding: 16px; border-radius: 18px; }
  .hero { padding-top: 20px; }
  .balloon { width: 44px; height: 66px; }
}
