/*
 * Myriad — site styles.
 *
 * Vanilla CSS. No framework, no CDN, no remote font, no build step. One file on
 * purpose: a second stylesheet is a second blocking round trip on shared
 * hosting, and this one is small enough not to need splitting.
 *
 * COLOUR RULE, and it is the one thing to keep when editing. Purple (#6900ff)
 * is the brand and carries the design as a BACKGROUND and BORDER colour — as
 * text on the dark page it measures 2.83:1 and fails AA at every size. Green
 * (#00ff00) is an accent only: focus rings, small labels, one word of emphasis.
 * As body text it is 1.37:1 on white and unreadable, and as a large fill it
 * reads as noise. Text is #f5f0ff (17.2:1) or #c9aeff (10.1:1).
 *
 * Measured ratios are in the report for this build; recompute rather than
 * eyeball if any of these values change.
 */

:root {
    /* Channels, not hex, where a translucent variant derives from the same
     * source — otherwise the two drift apart the first time one is edited. */
    --green-rgb: 0, 255, 0;
    --purple-rgb: 105, 0, 255;

    --bg-page: #1a0033;
    --bg-panel: #2e0073;
    --bg-surface: #3d0099;

    --purple-brand: rgb(var(--purple-rgb));
    --purple-deep: #5500cc;
    --green-accent: rgb(var(--green-rgb));

    --text-primary: #f5f0ff;
    --text-muted: #c9aeff;
    --white: #ffffff;

    --radius: 10px;
    --radius-pill: 999px;
    --max-width: 1100px;
    --showcase-max-width: 960px;

    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
}

/* -------------------------------------------------------------------------
 * Document
 * ---------------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-stack);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-page);
    background-image: radial-gradient(circle at 50% 0, var(--bg-panel), var(--bg-page) 60%);
    background-attachment: fixed;
    /* Nothing on this page may scroll the document sideways. Checked at 360px. */
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--text-primary);
}

h1,
h2,
h3 {
    line-height: 1.2;
    margin: 0 0 0.5em;
}

/* One focus style for everything, and it is green because green is the one
 * colour in this palette that is unmistakable against every surface here. */
:focus-visible {
    outline: 3px solid var(--green-accent);
    outline-offset: 3px;
    border-radius: 3px;
}

/* -------------------------------------------------------------------------
 * Helpers
 * ---------------------------------------------------------------------- */

.wrap {
    width: 100%;
    max-width: var(--max-width);
    margin-inline: auto;
    padding-inline: 1.25rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: 0.75rem 1.25rem;
    background: var(--bg-surface);
    color: var(--text-primary);
    text-decoration: none;
}

.skip-link:focus {
    left: 0;
}

/* -------------------------------------------------------------------------
 * Buttons
 * ---------------------------------------------------------------------- */

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: 2px solid transparent;
    border-radius: var(--radius-pill);
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    /* 44px minimum target: 0.75rem padding + 2px border either side + line-box. */
    min-height: 44px;
    transition: background-color 150ms ease, border-color 150ms ease;
}

/* The brand colour as a fill with white on top — 6.90:1, which is where purple
 * belongs. Hover goes DARKER, not lighter: lightening the fill would push the
 * white text down towards the AA boundary rather than away from it. */
.btn--primary {
    background: var(--purple-brand);
    border-color: var(--purple-brand);
    color: var(--white);
}

.btn--primary:hover,
.btn--primary:focus-visible {
    background: var(--purple-deep);
    border-color: var(--purple-deep);
}

.btn--ghost {
    background: transparent;
    border-color: var(--purple-brand);
    color: var(--text-primary);
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
    background: rgba(var(--purple-rgb), 0.3);
}

/* .btn was written for <a>. A <button> inherits neither the page's font nor a
 * pointer cursor from it, so both are set here rather than in .btn, which would
 * be repeating what a link already does. */
button.btn {
    font-family: inherit;
    cursor: pointer;
}

/* .btn sets display:inline-block, which OVERRIDES the user agent's
 * [hidden] { display: none } — without this line every control the JavaScript
 * is supposed to reveal is visible before it runs, and dead if it never does. */
.btn[hidden] {
    display: none;
}

/* -------------------------------------------------------------------------
 * Header
 * ---------------------------------------------------------------------- */

.site-header {
    border-bottom: 1px solid rgba(var(--purple-rgb), 0.5);
    background: rgba(26, 0, 51, 0.85);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(8px);
}

.site-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    padding-block: 0.75rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    text-decoration: none;
    color: var(--text-primary);
}

/* Still in use: 404.php carries its own copy of the masthead with the lettered
 * mark, and that file is closed to edits. The image mark below is the site's. */
.brand__mark {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius);
    background: var(--purple-brand);
    color: var(--white);
    font-size: 1.1rem;
    line-height: 1;
}

.brand__logo {
    /* flex: none, or the badge is the first thing squashed when the masthead
     * runs out of room at 360px. */
    flex: none;
    width: 2rem;
    height: 2rem;
}

.brand__text {
    display: grid;
    line-height: 1.15;
}

.brand__name-accent {
    color: var(--text-muted);
    font-weight: 500;
}

/* The motto, in Latin — italic because it is, and marked lang="la" in the
 * markup so a screen reader does not read it as English. */
.brand__motto {
    font-size: 0.6875rem;
    font-weight: 600;
    font-style: italic;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.site-nav__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav__link {
    display: inline-block;
    padding: 0.5rem 0.25rem;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.site-nav__link:hover,
.site-nav__link:focus-visible {
    border-bottom-color: var(--green-accent);
}

.site-nav__link--cta {
    padding-inline: 1rem;
    border: 2px solid var(--purple-brand);
    border-radius: var(--radius-pill);
}

.site-nav__link--cta:hover,
.site-nav__link--cta:focus-visible {
    background: rgba(var(--purple-rgb), 0.35);
    border-bottom-color: var(--purple-brand);
}

/* -------------------------------------------------------------------------
 * Nav disclosure menu
 * ---------------------------------------------------------------------- */

/*
 * NOT RENDERED TODAY, AND THAT IS RECORDED HERE ON PURPOSE. partials/header.php
 * emits this markup only when lib/rules-nav.php holds more than one rules page;
 * with one it emits a plain link, because a menu whose whole contents is a single
 * link is a widget in exchange for nothing. The styles ship now so that adding a
 * second game is a data change rather than a design job, and
 * scripts/check-ttt-rules.php renders the two-entry masthead so this path is
 * checked rather than merely present.
 *
 * IT IS <details>/<summary> AND IT CARRIES NO JAVASCRIPT. The browser gives a
 * <summary> a button role and keeps its expanded state exposed by itself, so
 * there is no aria-expanded here to desync from what is on screen; it opens from
 * the keyboard, it works on a touch screen because it is a real click target and
 * not a :hover, and it works with JavaScript off — which anything standing
 * between a player and the rules has to. What it does not do without script is
 * close on Escape or on a click elsewhere.
 *
 * Nothing below uses :hover to OPEN the menu. Hover only tints what is already
 * open, exactly like the other nav links.
 */

.nav-menu {
    position: relative;
}

/* The disclosure triangle is the browser's, and it is removed: this sits in a row
 * of nav links and the marker made it the only item with a glyph beside it. The
 * ::after arrow below replaces it, so the menu still says it is a menu. */
.nav-menu__button {
    /* .site-nav__link supplies the colour, padding and the underline-on-hover. */
    cursor: pointer;
    list-style: none;
    /* Safari needs this one; ::marker alone does not remove the triangle there. */
    -webkit-appearance: none;
}

.nav-menu__button::-webkit-details-marker {
    display: none;
}

.nav-menu__button::marker {
    content: '';
}

.nav-menu__button::after {
    content: '';
    display: inline-block;
    width: 0.4em;
    height: 0.4em;
    margin-left: 0.45em;
    vertical-align: 0.15em;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
}

.nav-menu[open] > .nav-menu__button::after {
    transform: rotate(-135deg);
}

/*
 * OPAQUE, and it has to be. The masthead is a blurred translucent bar; a
 * translucent panel hanging below it would composite over whatever the page
 * happens to be scrolled to, and no contrast figure could be computed for the
 * text on it. #2e0073 gives #f5f0ff 13.78:1.
 */
.nav-menu__list {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 30;
    min-width: 11rem;
    margin: 0.25rem 0 0;
    padding: 0.375rem;
    border: 1px solid rgba(var(--purple-rgb), 0.6);
    border-radius: var(--radius);
    background: var(--bg-panel);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    list-style: none;
}

.nav-menu__link {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
}

.nav-menu__link:hover,
.nav-menu__link:focus-visible {
    background: rgba(var(--purple-rgb), 0.35);
}

/*
 * Below 600px the masthead is already two or three rows tall and an absolutely
 * positioned panel would hang over the page content from a bar that moves. The
 * menu becomes an inline list that pushes the header taller instead, which is
 * honest about the space it takes and is why scroll-margin-top is generous there.
 */
@media (max-width: 599px) {
    .nav-menu__list {
        position: static;
        min-width: 0;
        box-shadow: none;
    }
}

/* -------------------------------------------------------------------------
 * Hero
 * ---------------------------------------------------------------------- */

.hero {
    padding-block: clamp(3rem, 9vw, 6rem);
    text-align: center;
}

/* The badge, at the size the artwork earns. The drop shadow is the brand purple
 * as light rather than as a fill — the one place a saturated colour can be
 * large without becoming a contrast problem, because nothing is read on it. */
.hero__logo {
    display: block;
    width: clamp(84px, 20vw, 112px);
    margin: 0 auto 1.25rem;
    filter: drop-shadow(0 0 24px rgba(var(--purple-rgb), 0.55));
}

.hero__eyebrow {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 0.6rem;
    margin: 0 0 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--green-accent);
}

.hero__motto {
    font-style: italic;
}

/* A border, not a "—" or a ::before, as the separator: punctuation put here
 * would be read out by some screen readers and means nothing when it is. */
.hero__motto-gloss {
    padding-left: 0.6rem;
    border-left: 1px solid rgba(var(--purple-rgb), 0.9);
    color: var(--text-muted);
    font-weight: 600;
}

.hero__title {
    font-size: clamp(2.25rem, 7vw, 4rem);
    font-weight: 800;
    margin-bottom: 1rem;
}

.hero__title-accent {
    color: var(--text-muted);
}

.hero__lead {
    max-width: 42rem;
    margin: 0 auto 2rem;
    font-size: clamp(1rem, 2.2vw, 1.1875rem);
    color: var(--text-muted);
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin: 0;
}

/* -------------------------------------------------------------------------
 * Sections
 * ---------------------------------------------------------------------- */

.section {
    padding-block: clamp(2.5rem, 7vw, 4.5rem);
}

/*
 * Reserve the sticky header's height above every anchor target.
 *
 * Without this, /#community and /#servers scroll their section to y=0 and the
 * header — sticky, opaque, z-index 20 — then covers the heading the visitor
 * clicked to reach. Measured before the fix: the h2 landed 122px inside the
 * header at 360px, 75px inside it at 480px, and 1px clear of it at 1440px,
 * which is not a margin, it is a coincidence.
 *
 * The three values ARE the measured header heights, because the nav wraps: one
 * row is 71px from 584px up, two rows are 115px from 372px, three rows are
 * 162px below that. The section's own padding-block supplies the visual gap on
 * top of the reserve, so these do not need slack of their own.
 */
/*
 * .rules-section[id] and .rules-part[id] are here rather than in ttt-rules.css so
 * these three measured values stay in ONE place. That page's contents list jumps
 * to 19 anchors and every one of them would land under the sticky header without
 * this. Adding the selector rather than copying the numbers is deliberate: two
 * copies of a measured value drift the first time the masthead changes.
 */
#main,
.section[id],
.rules-section[id],
.rules-part[id] {
    scroll-margin-top: 10.5rem;
}

@media (min-width: 380px) {
    #main,
    .section[id],
    .rules-section[id],
    .rules-part[id] {
        scroll-margin-top: 7.5rem;
    }
}

@media (min-width: 600px) {
    #main,
    .section[id],
    .rules-section[id],
    .rules-part[id] {
        scroll-margin-top: 4.5rem;
    }
}

.section--panel {
    background: rgba(46, 0, 115, 0.55);
    border-block: 1px solid rgba(var(--purple-rgb), 0.4);
}

.section__title {
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    font-weight: 800;
}

.section__lead {
    max-width: 44rem;
    margin: 0 0 2rem;
    color: var(--text-muted);
}

/* -------------------------------------------------------------------------
 * Showcase
 * ---------------------------------------------------------------------- */

.showcase {
    position: relative;
    max-width: var(--showcase-max-width);
    margin-inline: auto;
}

/*
 * A fixed 16/9 box. Screenshots arrive at whatever aspect ratio the sender's
 * monitor had, and without this the page height jumps every time the rotation
 * lands on a differently shaped one.
 */
.showcase__viewport {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid rgba(var(--purple-rgb), 0.5);
    background: var(--bg-panel);
}

.showcase__track {
    position: absolute;
    inset: 0;
}

.showcase__slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    /* visibility, not opacity alone: an opacity-0 image is still in the
     * accessibility tree, and a screen reader then reads every slide's alt
     * text in one run. aria-hidden on the element and this must agree. */
    visibility: hidden;
    transition: opacity 600ms ease;
}

.showcase__slide.is-active {
    opacity: 1;
    visibility: visible;
}

/*
 * With JavaScript off, the rotation never starts and only the first slide ever
 * has a src — so it is the one that shows, statically, and the visitor gets a
 * screenshot rather than an empty box. Nothing else needs saying here; the
 * remaining slides have no src at all, so there is nothing to render broken.
 */

.showcase__control {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(var(--purple-rgb), 0.7);
    border-radius: 50%;
    background: rgba(26, 0, 51, 0.8);
    color: var(--text-primary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.showcase__control:hover {
    background: var(--purple-brand);
    color: var(--white);
}

.showcase__control--prev {
    left: 0.75rem;
}

.showcase__control--next {
    right: 0.75rem;
}

.showcase__control--toggle {
    position: static;
    transform: none;
    width: 40px;
    height: 40px;
}

/* Drawn in CSS, not typed as U+23F8 / U+25B6: those render as full-colour
 * emoji on Windows and Android, which ignores the button's own colour. */
.showcase__icon {
    display: block;
    width: 12px;
    height: 14px;
    background: currentColor;
}

.showcase__control--toggle[data-state="playing"] .showcase__icon {
    background: linear-gradient(
        to right,
        currentColor 0 35%,
        transparent 35% 65%,
        currentColor 65% 100%
    );
}

.showcase__control--toggle[data-state="paused"] .showcase__icon {
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.showcase__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.75rem;
}

.showcase__counter {
    margin: 0;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

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

.showcase--empty {
    display: grid;
    justify-items: center;
    gap: 0.5rem;
    padding: clamp(2rem, 8vw, 4rem) 1.25rem;
    border: 1px dashed rgba(var(--purple-rgb), 0.7);
    border-radius: var(--radius);
    text-align: center;
    color: var(--text-muted);
}

.showcase__placeholder {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.showcase__hint {
    margin: 0;
}

/* -------------------------------------------------------------------------
 * Servers
 * ---------------------------------------------------------------------- */

.servers,
.links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.server {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.5rem;
    border: 1px solid rgba(var(--purple-rgb), 0.55);
    border-radius: var(--radius);
    background: rgba(61, 0, 153, 0.35);
    transition: border-color 150ms ease, background-color 150ms ease;
}

.server:hover {
    border-color: rgba(var(--purple-rgb), 0.9);
    background: rgba(61, 0, 153, 0.5);
}

/* Which game this server is. It exists because the lineup stopped being one
 * game: without it a visitor reads the second card as another Garry's Mod
 * server. align-self keeps the pill the width of its text, not the card. */
.server__game {
    align-self: flex-start;
    margin: 0 0 0.6rem;
    padding: 0.1rem 0.65rem;
    border: 1px solid rgba(var(--purple-rgb), 0.85);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.server__name {
    font-size: 1.25rem;
    font-weight: 800;
}

.server__blurb {
    margin: 0 0 1rem;
    color: var(--text-muted);
}

.server__address {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
}

.server__address-label {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--green-accent);
}

.server__address-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    /* An IPv4:port is long and the card is narrow at 360px. */
    overflow-wrap: anywhere;
    color: var(--text-muted);
}

/* How to get in when the game has no join link. Sits with the address it
 * explains rather than with the buttons. */
.server__note {
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.server__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: auto 0 0;
}

/* Green is the accent, and this is what an accent is for: one confirmation,
 * briefly, on a control the visitor just pressed. */
.server__copy.is-copied {
    border-color: var(--green-accent);
}

/* -------------------------------------------------------------------------
 * Link cards
 * ---------------------------------------------------------------------- */

.link-card {
    display: grid;
    gap: 0.35rem;
    height: 100%;
    padding: 1.25rem 1.5rem;
    border: 1px solid rgba(var(--purple-rgb), 0.45);
    border-radius: var(--radius);
    background: rgba(46, 0, 115, 0.4);
    text-decoration: none;
    transition: border-color 150ms ease, background-color 150ms ease;
}

.link-card:hover,
.link-card:focus-visible {
    border-color: var(--green-accent);
    background: rgba(61, 0, 153, 0.55);
}

.link-card__title {
    font-size: 1.125rem;
    font-weight: 800;
}

.link-card__blurb {
    color: var(--text-muted);
}

/* -------------------------------------------------------------------------
 * Footer
 * ---------------------------------------------------------------------- */

.site-footer {
    margin-top: clamp(2.5rem, 7vw, 4.5rem);
    padding-block: 2rem;
    border-top: 1px solid rgba(var(--purple-rgb), 0.5);
    background: rgba(26, 0, 51, 0.8);
    font-size: 0.9375rem;
}

.site-footer__inner {
    display: grid;
    gap: 0.75rem;
}

.site-footer__brand {
    margin: 0;
    font-weight: 700;
}

.site-footer__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-footer__list a {
    color: var(--text-muted);
}

.site-footer__list a:hover,
.site-footer__list a:focus-visible {
    color: var(--text-primary);
}

.site-footer__legal {
    margin: 0;
    color: var(--text-muted);
}

/* -------------------------------------------------------------------------
 * Reduced motion
 * ---------------------------------------------------------------------- */

/*
 * Durations collapsed to 0.01ms rather than `animation: none`. A blanket none
 * cancels animations that some code is waiting to END — the animationend
 * listener never fires and whatever it was going to do never happens. A
 * duration this short finishes instantly and still fires.
 *
 * The auto-rotation itself is stopped in JavaScript, not here: CSS can flatten
 * a transition but it cannot stop a setInterval swapping the picture.
 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    html {
        scroll-behavior: auto;
    }
}
