/* Course Cards. Phone first, fluid at every width: one column that grows to a
   comfortable reading width on a tablet or desktop. Nothing here is sized for
   one screen (the old tablet site was). Colours are the Mendip App's, so the
   app reads as part of it inside the App's frame. */

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1a1a2e;
  --muted: #6b7280;
  --line: #dde1e7;
  --brand: #005e85;
  --brand-dark: #004669;
  --brand-light: #e8f4fd;
  --ok: #1f8a4c;
  --ok-light: #e3f5ea;
  --tried: #b26a00;
  --tried-light: #fff3df;
  --warn-bg: #fff4dd;
  --warn-line: #f0c46a;
  --ski: #2f6fdb;
  --board: #8a4fc7;
  --mini: #1f9a62;
  --radius: 12px;
  --tap: 48px;                 /* the smallest thing a cold thumb has to hit */
  --wrap: 760px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); }
button, input, textarea, select { font: inherit; color: inherit; }
.ico { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ── Header bar ─────────────────────────────────────────────────────────── */
.bar { position: sticky; top: 0; z-index: 50; background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.bar__in {
  max-width: var(--wrap); margin: 0 auto; min-height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-left));
  padding-top: env(safe-area-inset-top);
}
.bar a { color: #fff; text-decoration: none; }
.bar__brand, .bar__back { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); font-weight: 600; }
.bar__back { margin-left: -6px; padding-right: 8px; }
.bar__user { margin-left: auto; font-size: .85rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: none; }
.bar__out { margin-left: auto; font-size: .9rem; padding: 8px 4px; opacity: .9; }
@media (min-width: 560px) { .bar__user { display: block; } .bar__user + .bar__out { margin-left: 0; } }

/* On a slope tablet: who's acting, and a Done that can't be missed. */
.bar__who { margin-left: auto; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bar__done { margin: 0; flex: none; }
.btn--done { background: #fff; color: var(--brand); min-width: 92px; font-size: 1rem; }
.btn--done:active { background: var(--brand-light); }

/* The names to tap (tablet.php): big, two or three across on a tablet. */
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 10px; margin: 0 0 18px; }
.name {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 84px; padding: 14px 16px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; text-align: left;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.name:active { background: var(--brand-light); border-color: var(--brand); }
.name.is-on { border-color: var(--brand); }
.name__who { font-size: 1.2rem; font-weight: 700; }
.name__meta { color: var(--muted); font-size: .9rem; }

/* Inside the Mendip App frame: a slim white strip, no sign out (the App owns it). */
body.embedded .bar { background: var(--panel); color: var(--ink); box-shadow: none; border-bottom: 1px solid var(--line); }
body.embedded .bar a { color: var(--brand); }
body.embedded .bar__in { min-height: 44px; padding-top: 0; }
body.embedded .bar__user, body.embedded .bar__out { display: none; }

/* ── Page ───────────────────────────────────────────────────────────────── */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 14px max(14px, env(safe-area-inset-left)) 90px; }
.page-head { margin: 4px 0 14px; }
.page-head h1 { font-size: 1.4rem; line-height: 1.2; margin: 0; overflow-wrap: anywhere; }
.page-sub { margin: 6px 0 0; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.page-sub strong { color: var(--ink); }

.block { margin: 0 0 22px; }
.block__h { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.fold > summary { cursor: pointer; list-style: none; min-height: var(--tap); }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "Show"; margin-left: auto; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--brand); }
.fold[open] > summary::after { content: "Hide"; }
.count { background: var(--line); color: var(--ink); border-radius: 999px; padding: 1px 8px; font-size: .75rem; letter-spacing: 0; }
.day { font-size: .95rem; margin: 16px 0 8px; }
.hint { margin: 0 0 10px; color: var(--muted); font-size: .9rem; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; color: var(--muted); margin: 0 0 12px; }
.context { display: flex; align-items: center; gap: 8px; color: var(--muted); margin: -6px 0 12px; font-size: .9rem; }

/* ── "Ticking as · Not you? Switch" (includes/acting.php; the Till's strip) ── */
.acting {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 14px;
}
.acting.is-switched { border-color: var(--brand); background: var(--brand-light); }
.acting__text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.2; }
.acting__label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.acting__name { font-size: 1.15rem; color: var(--brand); overflow-wrap: anywhere; }
.acting__login { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.acting .btn { margin-left: auto; flex: none; white-space: nowrap; padding-left: 12px; padding-right: 12px; }

.face {
  position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: var(--brand-light); color: var(--brand); display: inline-grid; place-items: center;
  font-weight: 700; font-size: .8rem; letter-spacing: .02em;
}
.face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.face--lg { width: 64px; height: 64px; font-size: 1rem; }
.face--sm { width: 26px; height: 26px; font-size: .62rem; }

/* Ticking as yourself: one quiet line (the tinted card above is for when someone has switched) */
.acting-line { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: .9rem; color: var(--muted); }
.acting-line strong { color: var(--ink); font-weight: 600; }
.acting-line a { margin-left: auto; font-weight: 600; text-decoration: none; padding: 6px 2px; }

/* The picker (switch.php) */
.pick__back { margin: 0 0 16px; }
.faces { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); gap: 10px; margin: 0 0 20px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; min-height: 120px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; text-align: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.tile:active, .tile.is-on { border-color: var(--brand); background: var(--brand-light); }
.tile__name { font-weight: 700; line-height: 1.2; }
.tile small { color: var(--muted); }
.people { max-height: 60vh; overflow-y: auto; }
.row--btn { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; min-height: 56px; }
.row--btn.is-on { background: var(--brand-light); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Go to any date (index.php) ─────────────────────────────────────────── */
.datenav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 16px; }
.datenav .btn { gap: 4px; padding-left: 10px; padding-right: 10px; }
.datenav__pick { flex: 1 1 9.5em; min-width: 0; }
.datenav__pick input {
  width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
  background: #fff; font-size: 16px; font-weight: 600;
}
.daysum { margin: 0 0 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--muted); }
.you { color: var(--brand); font-weight: 700; }

/* ── Lists of rows (lessons, people) ────────────────────────────────────── */
.list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 64px; color: var(--ink); text-decoration: none; }
a.row:active { background: var(--brand-light); }
@media (hover: hover) { a.row:hover { background: #f8fafc; } }
.row__time { flex: none; width: 3.4em; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.row__time small { display: block; font-weight: 400; color: var(--muted); }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row__title { font-weight: 600; overflow-wrap: anywhere; }
.row__title small { font-weight: 400; color: var(--muted); }
.row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--muted); font-size: .85rem; }
.row__go { color: var(--muted); }

.booking { font-size: .85rem; font-weight: 600; color: var(--muted); margin: 0 0 6px; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.booking__ref {
  display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 2px 10px; border-radius: 999px;
  background: var(--brand-light); color: var(--brand); letter-spacing: .03em; text-decoration: none; font-weight: 700;
}
.booking__ref:active { background: #d3e9f8; }
.booking__who { color: var(--ink); font-weight: 600; }
.person { padding-bottom: 2px; }
.person > .btn--block { margin: 0 14px 12px; width: calc(100% - 28px); }
.nocard { color: #b42318; font-weight: 600; }

.pill { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: .75rem; font-weight: 700; color: #fff; letter-spacing: .02em; }
.pill--ski { background: var(--ski); }
.pill--board { background: var(--board); }
.pill--mini { background: var(--mini); }
.progress { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); }
.progress.is-done { color: var(--ok); font-weight: 600; }

/* Suggested cards for someone with none */
.suggest { margin: 0 14px 10px; }
.suggest__h { margin: 0 0 6px; font-size: .85rem; font-weight: 600; }
.suggest__card {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  background: var(--brand-light); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px;
}
.suggest__card > div { display: flex; flex-direction: column; min-width: 0; flex: 1 1 14em; }
/* A card that probably isn't theirs (card_fit): amber, with the reason, and its button quiet */
.suggest__card.is-unlikely { background: var(--warn-bg); border: 1px solid var(--warn-line); border-left: 4px solid #d97706; }
.fit-warn { display: flex; align-items: flex-start; gap: 6px; margin: 6px 0 0; color: #92400e; font-size: .85rem; line-height: 1.35; }
.fit-warn .ico { flex: none; color: #d97706; margin-top: 1px; }

/* ── Buttons and fields ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px; border: 0; border-radius: 10px;
  background: var(--brand); color: #fff; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { background: var(--brand-dark); }
.btn--small { min-height: 40px; padding: 8px 14px; font-size: .9rem; }
.btn--quiet { background: var(--panel); color: var(--brand); border: 1px solid var(--line); }
.btn--quiet:active { background: var(--brand-light); }
.btn--block { display: flex; width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .6; pointer-events: none; }
.btn--danger { background: #b42318; }
.btn--danger:active { background: #8f1c13; }

/* A wide page (card admin's list + card side by side on a desktop). */
body.wide .wrap, body.wide .bar__in { max-width: 1500px; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; font-weight: 600; font-size: .9rem; }
.field input, .notebox textarea {
  width: 100%; min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: #fff; font-weight: 400; font-size: 16px;      /* 16px: iOS zooms in on anything smaller */
}
.field input:focus, .notebox textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.search { display: grid; grid-template-columns: 1fr; gap: 0 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 18px; }
@media (min-width: 560px) { .search { grid-template-columns: 1fr 1fr auto; align-items: end; } .search .btn { margin-bottom: 12px; } }
.newcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.form-error { color: #b42318; margin: 10px 0 0; font-weight: 600; }
.found { padding: 12px 14px; }
.found__who { display: flex; flex-direction: column; margin-bottom: 8px; }
.found .suggest__card { margin: 0 0 6px; }

.note { background: var(--brand-light); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
.note--warn { background: var(--warn-bg); border: 1px solid var(--warn-line); }
.note--act { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; background: var(--warn-bg); border: 1px solid var(--warn-line); }
.note--act p { margin: 0; flex: 1 1 14em; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.login-box { max-width: 420px; margin: 0 auto; }
.login-box h2 { margin-top: 0; }

/* ── The card: level chips, skills, ticks ───────────────────────────────── */
.chips {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * max(14px, env(safe-area-inset-left))) 12px; padding: 2px max(14px, env(safe-area-inset-left)) 8px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  font-weight: 600; cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.chip small { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.is-done { border-color: var(--ok); color: var(--ok); }
.chip.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.is-on small { color: rgba(255,255,255,.85); }
@media (min-width: 760px) { .chips { flex-wrap: wrap; overflow: visible; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; } }

.level { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.level__h { margin: 0 0 10px; font-size: 1.15rem; }
.level__h small { font-size: .85rem; font-weight: 400; color: var(--muted); }
.skills { list-style: none; margin: 0; padding: 0; }
.skill { padding: 12px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr; gap: 10px; }
.skill:first-child { border-top: 0; padding-top: 2px; }
.skill__name { font-weight: 600; overflow-wrap: anywhere; }
.skill.is-retired .skill__name { color: var(--muted); }
.skill__ticks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 620px) {
  .skill { grid-template-columns: 1fr 300px; align-items: center; }
}

.tick {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 8px;
  min-height: 56px; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); background: #fff;
  text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.tick__box {
  grid-row: span 2; width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--line);
  display: grid; place-items: center; color: transparent; background: #fff;
}
.tick__label { font-weight: 700; line-height: 1.15; }
.tick__by { color: var(--muted); font-size: .75rem; line-height: 1.2; min-height: 1em; }
.tick--tried.is-on { border-color: var(--tried); background: var(--tried-light); }
.tick--tried.is-on .tick__box { background: var(--tried); border-color: var(--tried); color: #fff; }
.tick--got.is-on { border-color: var(--ok); background: var(--ok-light); }
.tick--got.is-on .tick__box { background: var(--ok); border-color: var(--ok); color: #fff; }
.tick[disabled] { cursor: default; opacity: .75; }
.tick.is-busy { opacity: .55; }
.tick.is-error { border-color: #b42318; }

.notebox { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.notebox__h { display: flex; align-items: center; gap: 6px; font-weight: 600; margin: 0 0 6px; }
.notebox textarea { resize: vertical; min-height: 88px; }
.notebox__act { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.history { margin-top: 12px; }
.history summary { cursor: pointer; color: var(--brand); font-weight: 600; min-height: 40px; display: flex; align-items: center; gap: 8px; }
.history ul { list-style: none; margin: 0; padding: 0; }
.history li { padding: 8px 0; border-top: 1px solid var(--line); }
.history p { margin: 2px 0 0; }

.foot-links { display: flex; flex-direction: column; gap: 4px; margin: 18px 0 0; }
.foot-links a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; text-decoration: none; }

/* A message that floats up after a tick: "Level complete" / an error */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 28px); background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 100; font-weight: 600;
}
.toast--ok { background: var(--ok); }
.toast--err { background: #b42318; }

/* The corner beta pill + feedback link, as every estate app has */
.beta-pill { position: fixed; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: .75rem; color: var(--muted); display: flex; gap: 6px; }
.beta-pill span:first-child { color: #b26a00; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.beta-pill a { color: var(--brand); text-decoration: none; }
