:root {
  --brand: #064294;        /* Aviantech logo blue */
  --brand-deep: #04306c;
  --sky: #188bf6;          /* aviantech.co accent */
  --ink: #15284a;
  --ink-soft: #52627d;
  --paper: #ffffff;
  --mist: #e3edfa;         /* available */
  --booked: #064294;       /* booked: solid brand blue */
  --wing: #5b7fbf;         /* soft-hold strokes */
  --line: #c3d2e8;
  --past: #f2f4f8;
  --on-brand: #ffffff;
  --on-brand-soft: #d9e5f7;
  --holiday: #b42318;      /* public holiday labels */
  --holiday-soft: #fdecea;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #0a3f8a;
    --brand-deep: #072f68;
    --ink: #e7eefb;
    --ink-soft: #a9b9d4;
    --paper: #0e1a2e;
    --mist: #1b3357;
    --booked: #7fb0ff;     /* brighter than brand so it stands out on the dark page */
    --wing: #8fb1e6;
    --line: #3a5480;
    --past: #121e33;
    --holiday: #ff9b8f;
    --holiday-soft: #3a1d22;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Lato", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

h1, h2, h3 { font-family: "Montserrat", system-ui, sans-serif; }

.page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
}

/* Brand panel */
.brand {
  position: relative;
  overflow: hidden;
  background: var(--brand);
  color: var(--on-brand);
}
.brand-inner {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  gap: 28px;
  padding: 40px 36px 48px;
}
.wing {
  position: absolute;
  right: -90px;
  bottom: -40px;
  width: 420px;
  opacity: 0.12;
  filter: brightness(0) invert(1);
  pointer-events: none;
}

.logo { display: inline-block; width: fit-content; }
.logo img { display: block; width: 150px; height: auto; }

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 1.3rem + 1.4vw, 2.35rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.lede { margin: 14px 0 0; color: var(--on-brand-soft); max-width: 40ch; }
.lede-link { color: #fff; font-weight: 700; text-underline-offset: 3px; white-space: nowrap; }

.brand-links { display: flex; flex-wrap: wrap; gap: 10px; }
.btn.on-brand { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.7); gap: 8px; }
.btn.on-brand:hover { background: rgba(255, 255, 255, 0.12); border-color: #fff; }

.legend {
  list-style: none; margin: 0; padding: 16px 18px;
  display: grid; gap: 10px; font-size: 0.95rem;
  background: var(--paper); color: var(--ink);
  border-radius: 14px;
}
.legend li { display: flex; align-items: center; gap: 12px; }

.swatch { width: 26px; height: 22px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1px var(--line); }
.swatch.free { background: var(--mist); }
.swatch.booked { background: var(--booked); box-shadow: none; }
.swatch.soft { background: var(--paper); background-image: var(--feathers); }
.swatch.unknown { background: var(--paper); background-image: var(--dots); background-size: 7px 7px; }
.swatch.split { background: linear-gradient(var(--mist) 0 50%, var(--booked) 50% 100%); }
.swatch.holiday { background: var(--paper); box-shadow: inset 3px 0 0 var(--holiday), inset 0 0 0 1px var(--line); }

/* Soft holds: near-horizontal swept strokes, taken from the wing feathers in the logo. */
:root { --feathers: repeating-linear-gradient(168deg, var(--wing) 0 2.5px, transparent 2.5px 7px); }
/* Beyond the published year: dotted, so it reads as "not known yet" rather than free. */
:root { --dots: radial-gradient(var(--ink-soft) 1.1px, transparent 1.4px); }

/* Selected-day card sits on the blue panel */
.panel {
  background: var(--paper);
  color: var(--ink);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(2, 25, 61, 0.28);
}
.panel-empty { margin: 0; color: var(--ink-soft); }
.panel h3 { margin: 0 0 4px; font-size: 1.15rem; font-weight: 700; }
.panel .sub { margin: 0 0 16px; color: var(--ink-soft); }
.halves { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; font-size: 0.95rem; }
.halves li { display: flex; align-items: center; gap: 10px; }
.actions { display: grid; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px;
  border-radius: 10px;
  border: 2px solid var(--brand);
  font: 700 0.95rem "Montserrat", system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn.secondary { background: transparent; color: var(--brand); }
@media (prefers-color-scheme: dark) { .btn.secondary { color: var(--ink); border-color: var(--wing); } }

/* Calendar */
.cal { padding: 40px clamp(20px, 4vw, 56px) 32px; min-width: 0; max-width: 980px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.cal-head h2 {
  margin: 0;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) { .cal-head h2 { color: var(--ink); } }
.nav-group { display: flex; gap: 8px; }
.nav {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--brand);
  font: 700 1.4rem/1 "Montserrat", sans-serif;
  cursor: pointer;
}
@media (prefers-color-scheme: dark) { .nav { color: var(--ink); } }
.nav:hover:not(:disabled) { border-color: var(--brand); }
.nav:disabled { opacity: 0.35; cursor: default; }

.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.weekdays { margin-bottom: 8px; color: var(--ink-soft); font: 600 0.82rem "Montserrat", sans-serif; }
.weekdays span { padding-left: 6px; }

.day {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 64px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr 1fr;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  box-shadow: inset 0 0 0 1px var(--line);
}
.day.blank { visibility: hidden; }
.day:disabled { cursor: default; }

.half { display: block; }
.half.free { background: var(--mist); }
.half.soft { background: var(--paper); background-image: var(--feathers); }
.half.booked { background: var(--booked); }
.half.unknown { background: var(--paper); background-image: var(--dots); background-size: 7px 7px; }
.half.past { background: var(--past); }
.half + .half { border-top: 2px solid var(--paper); }

.num {
  position: absolute; top: 6px; left: 7px;
  font: 700 0.95rem "Montserrat", sans-serif;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px; border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.day.is-past .num { color: var(--ink-soft); background: transparent; }

/* Public holidays: a label only, the halves keep their availability colours. */
.day.is-holiday .num { color: var(--holiday); }
.hol {
  position: absolute; left: 5px; right: 5px; bottom: 5px;
  font: 700 0.68rem/1.2 "Lato", sans-serif;
  color: var(--holiday);
  background: var(--paper);
  border-left: 3px solid var(--holiday);
  border-radius: 5px;
  padding: 2px 5px 2px 6px;
  hyphens: auto;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.day.is-past .hol { opacity: 0.6; }
.hol-pill {
  margin: 0 0 12px; padding: 8px 12px;
  border-radius: 10px;
  background: var(--holiday-soft);
  color: var(--holiday);
  font-size: 0.92rem;
}
.hol-pill b { display: block; }

.holidays { margin: 18px 0 0; padding: 16px 18px; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.holidays h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 700; }
.holidays .sub { margin: 0 0 12px; color: var(--ink-soft); font-size: 0.9rem; }
.holidays ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.holidays li { display: grid; grid-template-columns: 8.5rem 1fr; gap: 12px; font-size: 0.95rem; }
.holidays li.none { display: block; color: var(--ink-soft); }
.holidays .when { font: 700 0.9rem "Montserrat", sans-serif; color: var(--holiday); font-variant-numeric: tabular-nums; }
.holidays .where { display: block; color: var(--ink-soft); font-size: 0.88rem; }

.day:not(:disabled):hover { box-shadow: inset 0 0 0 2px var(--sky); }
.day[aria-selected="true"] { box-shadow: 0 0 0 3px var(--brand); }
@media (prefers-color-scheme: dark) { .day[aria-selected="true"] { box-shadow: 0 0 0 3px var(--sky); } }
.day:focus-visible, .nav:focus-visible, .btn:focus-visible, .logo:focus-visible {
  outline: 3px solid var(--sky); outline-offset: 2px;
}

.status { min-height: 1.5em; margin: 14px 0 0; color: var(--ink-soft); }
.status.error { color: #c0322b; }
.foot { margin: 8px 0 0; color: var(--ink-soft); font-size: 0.9rem; max-width: 70ch; }

@media (max-width: 900px) {
  .page { grid-template-columns: 1fr; }
  .brand-inner { position: static; padding: 24px 16px 28px; gap: 20px; }
  .logo img { width: 120px; }
  .wing { width: 300px; right: -80px; bottom: auto; top: 10px; }
  .cal { padding: 24px 16px; }
  /* On phones app.js moves the day card under the calendar. */
  .cal .panel { margin-top: 20px; box-shadow: 0 0 0 1px var(--line); }
  .weekdays, .grid { gap: 4px; }
  .day { min-height: 0; aspect-ratio: 1 / 1.15; border-radius: 8px; }
  .num { top: 3px; left: 3px; font-size: 0.82rem; padding: 0 4px; }
  .hol { left: 2px; right: 2px; bottom: 2px; font-size: 0.56rem; padding: 1px 2px 1px 3px; border-left-width: 2px; border-radius: 4px; }
  .holidays { padding: 14px; }
  .holidays li { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: no-preference) {
  .grid.reveal .day { animation: glide 380ms ease-out both; animation-delay: calc(var(--i) * 10ms); }
  @keyframes glide { from { opacity: 0; transform: translateX(-6px); } }
}
