/* ============================================================
   Bedford Family Wordle — "Authentic Wordle" design system
   MOBILE-FIRST (it's a home-screen PWA). Light is the priority
   theme; dark mirrors NYT Wordle's dark palette.
   ============================================================ */

:root {
    /* surfaces & ink (light) */
    --bg:        #ffffff;
    --surface:   #ffffff;
    --surface-2: #f6f7f8;
    --ink:       #1a1a1b;   /* Wordle text */
    --ink-soft:  #6e7174;
    --line:      #d3d6da;   /* Wordle tile/key border */
    --line-soft: #ececed;

    /* the Wordle tile palette (light) */
    --green:  #6aaa64;
    --yellow: #c9b458;
    --grey:   #787c7e;
    --fail:   #3a3a3c;
    --on-tile:#ffffff;

    --accent: var(--green);

    /* type */
    --font-display: "Bricolage Grotesque", system-ui, sans-serif;
    --font-body:    "Hanken Grotesk", system-ui, -apple-system, sans-serif;
    --font-mono:    "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;

    --radius: 6px;
    --maxw: 720px;
}

[data-theme="dark"] {
    --bg:        #121213;   /* real Wordle dark bg */
    --surface:   #1a1a1b;
    --surface-2: #26272b;
    --ink:       #d7dadc;
    --ink-soft:  #8a8d8f;
    --line:      #3a3a3c;
    --line-soft: #2c2c2e;

    --green:  #538d4e;      /* Wordle dark-mode green */
    --yellow: #b59f3b;      /* Wordle dark-mode yellow */
    --grey:   #565758;
    --fail:   #2a2a2c;
    --on-tile:#ffffff;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

a { color: var(--ink); text-decoration: none; }

/* ---------- header (mobile baseline) ---------- */
.site-header {
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 20;
}
.site-header__inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* wordmark built from Wordle tiles */
.wordmark { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.wordmark__tiles { display: flex; gap: 3px; }
.wordmark__sub {
    display: none;   /* hidden on phones, shown ≥560px */
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.74rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    line-height: 1.05;
    max-width: 5.2em;
}

.tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 0.82rem;
    text-transform: uppercase;
    color: var(--on-tile);
    border-radius: 3px;
    user-select: none;
}
.tile--green  { background: var(--green); }
.tile--yellow { background: var(--yellow); }
.tile--grey   { background: var(--grey); }

/* one-time gentle reveal (Wordle flips its tiles) */
.wordmark__tiles .tile { animation: tile-in 360ms ease both; }
.wordmark__tiles .tile:nth-child(2) { animation-delay: 50ms; }
.wordmark__tiles .tile:nth-child(3) { animation-delay: 100ms; }
.wordmark__tiles .tile:nth-child(4) { animation-delay: 150ms; }
.wordmark__tiles .tile:nth-child(5) { animation-delay: 200ms; }
.wordmark__tiles .tile:nth-child(6) { animation-delay: 250ms; }
.wordmark__tiles .tile:nth-child(7) { animation-delay: 300ms; }
@keyframes tile-in {
    0%   { transform: rotateX(-90deg); opacity: 0; }
    100% { transform: rotateX(0);      opacity: 1; }
}

/* nav */
.nav { display: flex; align-items: center; gap: 0.1rem; flex: 0 0 auto; }
.nav__link {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.84rem;
    color: var(--ink-soft);
    padding: 0.35rem 0.5rem;
    border-radius: 999px;
    transition: color 0.15s, background 0.15s;
}
.nav__link:hover  { color: var(--ink); background: var(--surface-2); }
.nav__link.is-active { color: var(--ink); background: var(--surface-2); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    background: none;
    color: var(--ink-soft);
    cursor: pointer;
    border-radius: 999px;
    padding: 0;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }

/* ---------- layout ---------- */
main {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 1.2rem 0.8rem 2.6rem;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.8rem;
    margin: 2rem 0 0.5rem;
}
.section-head:first-of-type { margin-top: 0.4rem; }

h1, h2 {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--ink);
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }

.meta {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--ink-soft);
    white-space: nowrap;
}

/* ---------- score chips (the Wordle "language") ---------- */
.chip {
    display: inline-block;
    min-width: 3.2em;
    text-align: center;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.18em 0.5em;
    border-radius: 4px;
    color: var(--on-tile);
}
.chip--green  { background: var(--green); }
.chip--yellow { background: var(--yellow); }
.chip--grey   { background: var(--grey); }
.chip--fail   { background: var(--fail); color: #d7dadc; box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- scoreboard rows (mobile-first; replaces wide tables) ---------- */
.board { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.board__row {
    display: grid;
    grid-template-columns: 1.7rem 1fr auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.45rem;
    border-bottom: 1px solid var(--line-soft);
}
.board__row:last-child { border-bottom: none; }
.board__rank {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--ink-soft);
    text-align: center;
}
.board__player { font-weight: 600; min-width: 0; }
.board__sub {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 400;
    color: var(--ink-soft);
    margin-top: 0.15rem;
}
.board__aside { display: flex; align-items: center; gap: 0.55rem; justify-self: end; }
.board__time { font-family: var(--font-mono); font-size: 0.74rem; color: var(--ink-soft); }
.board__score { font-family: var(--font-mono); font-weight: 700; font-size: 1.05rem; justify-self: end; }

/* daily leader gets a quiet moment */
.board__row.is-leader {
    background: color-mix(in srgb, var(--green) 10%, transparent);
    border-radius: 6px;
    border-bottom-color: transparent;
}
.board__row.is-leader .board__rank { color: var(--green); }
.crown { margin-left: 0.3rem; }

/* column headers for the boards (kept light) */
.board-head {
    display: grid;
    grid-template-columns: 1.7rem 1fr auto;
    gap: 0.6rem;
    padding: 0 0.45rem 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line);
}
.board-head span:last-child { justify-self: end; }

/* ---------- history cards ---------- */
.grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: 1fr;
    margin-top: 0.6rem;
}
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
}
.card__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding-bottom: 0.55rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid var(--line-soft);
}
.card__puzzle { font-family: var(--font-display); font-weight: 800; font-size: 1.02rem; }
.card__date { font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-soft); }
.card__winner { font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 0.4rem; }
.card__winner strong { color: var(--ink); font-weight: 600; }
.card .board__row { padding: 0.4rem 0; grid-template-columns: 1fr auto; }

/* ---------- notices ---------- */
.empty {
    text-align: center;
    color: var(--ink-soft);
    padding: 2rem 1rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    margin-top: 0.6rem;
}
.note {
    margin-top: 0.7rem;
    padding: 0.5rem 0.7rem;
    background: color-mix(in srgb, var(--yellow) 16%, transparent);
    border-left: 3px solid var(--yellow);
    border-radius: 4px;
    font-size: 0.82rem;
    color: var(--ink);
}
.note--preseason {
    background: color-mix(in srgb, var(--green) 12%, transparent);
    border-left-color: var(--green);
    font-size: 0.76rem;
    margin-top: 0.55rem;
}
.hot-ding { margin-left: 0.3rem; cursor: help; opacity: 0.85; }

/* ---------- rules dialog ---------- */
dialog {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    max-width: 460px;
    width: calc(100% - 1.6rem);
    padding: 1.4rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
dialog::backdrop { background: rgba(0,0,0,0.5); }
dialog h2 { margin-bottom: 0.7rem; }
dialog ul { padding-left: 1.1rem; line-height: 1.55; margin: 0; }
dialog li { margin-bottom: 0.5rem; }
dialog .btn {
    margin-top: 1.3rem;
    background: var(--green);
    color: #fff;
    border: none;
    font-family: var(--font-display);
    font-weight: 700;
    padding: 0.55rem 1.2rem;
    border-radius: 999px;
    cursor: pointer;
}

/* ---------- footer ---------- */
.site-footer {
    text-align: center;
    color: var(--ink-soft);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.6;
    padding: 2rem 1rem 2.6rem;
    border-top: 1px solid var(--line-soft);
}

/* ---------- a11y & motion ---------- */
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
    .wordmark__tiles .tile { animation: none; }
}

/* very narrow / magnified screens (e.g. iOS Display Zoom ≈ 320px):
   stack so they never collide — nav row on top, "BEDFORD" wordmark below */
@media (max-width: 400px) {
    .site-header__inner {
        flex-direction: column-reverse;
        align-items: center;
        gap: 0.45rem;
    }
    .nav { width: 100%; justify-content: center; gap: 0.15rem; }
}

/* ============================================================
   ≥ 560px — tablet/desktop enhancements
   ============================================================ */
@media (min-width: 560px) {
    html, body { font-size: 17px; }
    .site-header__inner { padding: 0.85rem 1.1rem; }
    .wordmark { gap: 0.7rem; }
    .wordmark__tiles { gap: 4px; }
    .wordmark__sub { display: block; }
    .tile { width: 1.9rem; height: 1.9rem; font-size: 1rem; }
    .nav { gap: 0.35rem; }
    .nav__link { font-size: 0.92rem; padding: 0.4rem 0.7rem; }
    .icon-btn { width: 2.1rem; height: 2.1rem; }
    .icon-btn svg { width: 19px; height: 19px; }

    main { padding: 1.6rem 1.1rem 3rem; }
    h1 { font-size: 2.1rem; }
    h2 { font-size: 1.35rem; }
    .section-head { margin-top: 2.6rem; }

    .board__row, .board-head { grid-template-columns: 2.4rem 1fr auto; gap: 0.8rem; padding-left: 0.6rem; padding-right: 0.6rem; }
    .board__row { padding-top: 0.75rem; padding-bottom: 0.75rem; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1rem; }
    .card .board__row { grid-template-columns: 1fr auto; }
}
