/* Family intranet, in the flere house style: light only, warm paper, white cards edged by a 1px
   border, pill buttons. Hanken Grotesk carries labels and headings; IBM Plex Mono carries badges,
   scores and small print. Both are self-hosted under ./fonts with their OFL licence texts.
   16 px base, 48 px targets, state never by colour alone (every state also has words or a mark),
   honours prefers-reduced-motion. */

@font-face {
  font-family: "Hanken Grotesk";
  src: url("./fonts/HankenGrotesk-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #faf8f5;
  --surface: #ffffff;
  --ink: #221f29;
  --muted: #7a7468;
  --faint: #a39c8e;
  --border: #e2ddd4;
  --border-soft: #f0ece4;
  --accent: #3f5d33;
  --accent-hover: #2f4726;
  --accent-soft: #e9efe2;
  --accent-border: #b9cfa9;
  --success: #3d7a48;
  --error: #b3403a;
  --error-soft: #fbeee7;
  --amber: #b06a1e;
  --amber-soft: #fdf3e6;
  --font: "Hanken Grotesk", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ring: rgba(63, 93, 51, 0.45);
  --radius: 16px;
  --radius-tile: 12px;
  --target: 48px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

input,
select {
  accent-color: var(--accent);
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 8px;
  top: -64px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  padding: 0 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.skip:focus {
  top: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- header: wordmark and the main nav ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* Lowercase flere plus a mono context badge, the same on every screen. */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--target);
  color: var(--ink);
  text-decoration: none;
}

.wordmark:hover {
  color: var(--ink);
}

.wordmark .brand {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
  line-height: 1;
}

.wordmark .badge {
  display: inline-block;
  padding: 3px 8px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.12em;
  line-height: 1.3;
  text-transform: uppercase;
}

/* "Picks Standings | Home Me": the open app's links, a divider, then the intranet's own. */
#nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}

.nav-app {
  position: relative;
  padding-right: 13px;
}

.nav-app::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 0;
  bottom: 10px;
  width: 1px;
  background: var(--border);
}

.topbar ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.topbar nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--target);
  min-width: var(--target);
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.topbar nav a:hover {
  color: var(--ink);
  border-color: var(--border);
}

/* Not colour alone: the current page also carries an edge, and aria-current names it. */
.topbar nav a[aria-current="page"] {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* ---------- page frame ---------- */

.view {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.view:focus {
  outline: none;
}

/* Desktop first: the home screen's cards sit in thirds on a wide frame; the board reads at a
   comfortable measure. Every other view keeps the 44 rem column. */
.view[data-view="home"] {
  max-width: 72rem;
}

.view[data-view="board"],
.view[data-view="requests"] {
  max-width: 48rem;
}

.card {
  width: 100%;
  margin: 0 0 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stack > * + * {
  margin-top: 12px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.lede,
.hint,
.aside {
  color: var(--muted);
}

.lede,
.hint {
  margin: 0;
}

.notice {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius-tile);
  background: var(--amber-soft);
}

.status {
  margin: 0;
  font-weight: 600;
  min-height: 1.5em;
}

.status[data-state="ok"],
.status[data-state="saved"] { color: var(--success); }
.status[data-state="maintenance"] { color: var(--amber); }
.status[data-state="error"] { color: var(--error); }
.status[data-state="unsaved"] { color: var(--amber); }

/* Not colour alone: a saved state also carries a check mark, as a saved pick does. */
.status[data-state="saved"]::before { content: "\2713\00a0"; }

.facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.facts div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  min-width: 0;
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}

/* ---------- forms ---------- */

.field label {
  display: block;
  font-weight: 700;
}

.field input,
.field textarea {
  display: block;
  width: 100%;
  min-height: var(--target);
  margin-top: 4px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-tile);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.15s;
}

.field input:hover,
.field textarea:hover {
  border-color: var(--faint);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field textarea {
  min-height: 7.5rem;
  line-height: 1.5;
  resize: vertical;
}

/* ---------- buttons: pills ---------- */

button {
  font: inherit;
}

.button,
.pick {
  min-height: var(--target);
  min-width: var(--target);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}

.button.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.button.secondary:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--ink);
}

.button:disabled,
.button:disabled:hover,
.pick:disabled,
.pick:disabled:hover {
  cursor: not-allowed;
  opacity: 0.4;
}

.button.secondary:disabled:hover,
.pick:disabled:hover {
  border-color: var(--border);
}

/* A pick is an inner tile: one side of a game. */
.pick {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-tile);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.pick:hover {
  border-color: var(--accent);
}

.pick[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px var(--accent-hover);
}

/* Not colour alone: the chosen side also gets a check mark and a thicker edge. */
.pick[aria-pressed="true"]::before {
  content: "\2713\00a0";
}

/* ---------- home: the app launcher ---------- */

.home {
  padding-top: 8px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.home h1 {
  margin: 0 0 28px;
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

/* A phone (and anything under 900 px): one centred column. */
.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 26rem);
  justify-content: center;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A desktop: always thirds, so one or two cards keep a third's width. */
@media (min-width: 900px) {
  .app-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    gap: 24px;
  }
}

.app-grid > li {
  display: flex;
  min-width: 0;
}

.app-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 220px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.16s, border-color 0.16s;
}

.app-card:hover,
.app-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--accent);
  color: var(--ink);
}

.app-card .label {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.app-card .sub {
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.app-card .open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  min-height: var(--target);
  margin-top: auto;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.app-card:hover .open {
  background: var(--accent-hover);
}

/* ---------- message board ---------- */

.board h1 {
  margin-bottom: 4px;
}

.board > .lede {
  margin-bottom: 20px;
}

.count {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

/* Not colour alone: over the limit also says how many too many. */
.count[data-state="over"] {
  color: var(--error);
}

.posts {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.post > * + * {
  margin-top: 8px;
}

.post-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.post-meta .author {
  color: var(--ink);
  font-weight: 700;
}

.post-meta time,
.post-meta .edited {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

/* Text only: line breaks kept, long words and links wrap instead of scrolling sideways. */
.post-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.post-actions .status {
  flex-basis: 100%;
}

.post-actions .status:empty {
  display: none;
}

.confirm {
  margin: 0;
  font-weight: 700;
}

.button.danger {
  background: var(--error);
  border-color: var(--error);
}

.button.danger:hover {
  background: #8f322d;
  border-color: #8f322d;
}

/* A post's thread: replies indented under a rule, oldest first, then the reply box. */
.thread-wrap {
  margin-top: 12px;
}

.thread {
  margin-top: 12px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}

.replies {
  margin: 0;
  padding: 0;
  list-style: none;
}

.reply {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}

.reply > * + * {
  margin-top: 6px;
}

.reply-form {
  margin-top: 12px;
}

.reply-form textarea {
  min-height: 4.5rem;
}

#show-new {
  margin-top: 4px;
}

#load-older {
  margin-top: 4px;
}

/* ---------- requests ---------- */

.requests-view h1 {
  margin-bottom: 4px;
}

.requests-view > .lede {
  margin-bottom: 20px;
}

.requests {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.request > * + * {
  margin-top: 8px;
}

.request-title {
  margin: 0;
  font-size: 1.125rem;
  overflow-wrap: anywhere;
}

/* Text only: line breaks kept, long words and links wrap instead of scrolling sideways. */
.request-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.request-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.request-meta .author {
  color: var(--ink);
  font-weight: 700;
}

.request-meta time {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.request-second {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.request-second .seconds {
  font-family: var(--mono);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.request-second .yours {
  color: var(--muted);
  font-size: 0.9375rem;
}

.request-second .status {
  flex-basis: 100%;
}

.request-second .status:empty {
  display: none;
}

/* ---------- week ---------- */

.weekhead > * + * {
  margin-top: 8px;
}

.weeknav,
.weeklinks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
  padding: 0;
  list-style: none;
}

.countdown {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

/* A content badge: a mono pill whose words carry the state; the edge colour only repeats it. */
.badge {
  display: inline-block;
  margin: 0;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}

.badge[data-state="final"] {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--success);
}

.badge[data-state="provisional"] {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
}

.games {
  margin: 0;
  padding: 0;
  list-style: none;
}

.game > * + * {
  margin-top: 8px;
}

.matchup {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.meta {
  margin: 0;
  color: var(--muted);
}

.provenance {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.pickrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.rowstatus {
  margin: 0;
  font-weight: 600;
}

.rowstatus[data-state="saved"] { color: var(--success); }
.rowstatus[data-state="rejected"] { color: var(--error); }
.rowstatus[data-state="locked"],
.rowstatus[data-state="unpickable"],
.rowstatus[data-state="void"] { color: var(--muted); }

/* A void game: greyed out (muted text on the page background, dashed edge) with a Void badge
   and its reason in words, never colour alone; it has no pick buttons. */
.game[data-state="void"] {
  background: var(--bg);
  border: 1px dashed var(--faint);
  color: var(--muted);
}

.voidbadge,
.badge.voidbadge {
  background: transparent;
  border-color: var(--faint);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.voidbadge[hidden],
.pickrow[hidden] {
  display: none;
}

.weekdate {
  margin: 0;
  font-weight: 700;
}

.rowstatus[data-state="locked"]::before { content: "\1F512\00a0"; }
.rowstatus[data-state="saved"]::before { content: "\2713\00a0"; }
.rowstatus[data-state="rejected"]::before { content: "\26A0\00a0"; }

.rowdetail > * + * {
  margin-top: 6px;
}

.score,
.outcome {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.score {
  font-family: var(--mono);
}

.others {
  margin: 6px 0 0;
  padding-left: 20px;
}

/* ---------- standings ---------- */

.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-tile);
  background: var(--surface);
}

.standings {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

.standings caption {
  padding: 12px 12px 8px;
  text-align: left;
  font-weight: 700;
}

.standings th,
.standings td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}

.standings thead th {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom-color: var(--border);
}

.standings tbody tr:last-child th,
.standings tbody tr:last-child td {
  border-bottom: 0;
}

.standings td {
  font-family: var(--mono);
}

/* Not colour alone: your own row is underlined and tinted. */
.standings tr[data-me="true"] {
  background: var(--accent-soft);
}

.standings tr[data-me="true"] th {
  text-decoration: underline;
}

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

  .app-card:hover,
  .app-card:focus-visible {
    transform: none;
  }
}
