/* ============================================================================
   Mexican Summer — shared component layer
   ----------------------------------------------------------------------------
   Loads after tokens.css and before a tool's own <style>, so anything a tool
   redefines at equal specificity still wins.

   Canonical page skeleton — every tool should open with this header so the
   back-link, the title and the header rule sit identically across tools:

     <header class="app-header">
       <div class="header-inner">
         <div class="header-lead">
           <a class="home-link" href="../index.html"><span class="caps">← Index</span></a>
           <h1 class="tty"><span class="caps">Tool Name</span></h1>
         </div>
         <div class="header-tools"> …buttons… </div>
       </div>
     </header>

   House rules worth knowing before adding to this file:
     • Containers are square-cornered, buttons are fully round (500px). That is
       the site's own logic — image blocks are hard-edged, pills are pills.
     • Avant Garde for anything set in caps (labels, buttons, headings, values);
       Helvetica Neue LT Pro for running text and inputs.
     • Orange is the only interaction colour: links, hover fills, focus rules,
       active tabs. Amber is reserved for warnings.
   ========================================================================= */

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

body {
    font-family: var(--f-nhg);
    background: var(--cream);
    color: var(--black);
    font-size: var(--t-body);
    letter-spacing: -.1px;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    /* Page end breathing room lives here once, not on every .panel. */
    padding-bottom: 88px;
}

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

/* Optically centre all-caps labels on the cap-height band, the way the
   site's pill buttons do — the line box otherwise reserves descender
   space that nothing in "SAVE" or "NEW" ever occupies. */
.caps {
    display: block;
    line-height: 1;
    text-box-trim: trim-both;
    text-box-edge: cap alphabetic;
}

/* ─────────── PAGE FRAME ─────────── */
/* Anything that should align to the same measure as the header takes .bleed. */
.bleed {
    max-width: var(--page-max);
    margin: 0 auto;
    padding-left: var(--page-pad);
    padding-right: var(--page-pad);
}

/* ─────────── HEADER ─────────── */
.app-header {
    background: rgba(240, 228, 207, .88);
    -webkit-backdrop-filter: saturate(1.2) blur(12px);
    backdrop-filter: saturate(1.2) blur(12px);
    border-bottom: 1px solid var(--black);
    position: sticky;
    top: 0;
    z-index: 60;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 12px var(--page-pad);
    flex-wrap: wrap;
    min-height: 62px;
}

.header-lead {
    display: flex;
    align-items: center;
    gap: 14px;
}

.tty {
    font-family: var(--f-ag-medium);
    font-size: 26px;
    font-weight: 400;
    letter-spacing: -.9px;
    text-transform: uppercase;
    color: var(--black);
    line-height: 1;
    margin: 0;
}

/* Extra Light, the weight the site reserves for MEXICAN SUMMER settings */
.home-link {
    font-family: var(--f-ag-xlight);
    font-size: 14px;
    letter-spacing: -.2px;
    text-transform: uppercase;
    color: var(--black);
    text-decoration: none;
    white-space: nowrap;
    transition: color .15s;
}

.home-link:hover {
    color: var(--orange);
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

/* ─────────── CONTROLS ─────────── */
button,
select,
input,
textarea {
    font-family: inherit;
    font-size: var(--t-body);
    color: var(--black);
}

/* Pill buttons, 500px radius and hover-fills-orange, exactly as .btn-shop.
   inline-block rather than inline-flex on purpose: text-box-trim needs a
   real text box to act on, and inside a flex container the bare label
   becomes an anonymous flex item and the trim silently does nothing. */
.btn {
    display: inline-block;
    line-height: 1;
    text-box-trim: trim-both;
    text-box-edge: cap alphabetic;
    background: transparent;
    border: 1.5px solid var(--black);
    border-radius: 500px;
    color: var(--black);
    font-family: var(--f-ag-book);
    font-size: 12px;
    letter-spacing: -.2px;
    text-transform: uppercase;
    padding: 8px 15px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}

.btn:hover {
    background: var(--orange);
    border-color: var(--orange);
    color: var(--white);
}

.btn-primary {
    background: var(--orange);
    border-color: var(--orange);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--black);
    border-color: var(--black);
    color: var(--white);
}

.btn-danger:hover {
    background: var(--black);
    border-color: var(--black);
    color: var(--white);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

/* Glyph buttons (✕ ⧉ ↺) have no cap-alphabetic band to trim to */
.btn-icon {
    padding: 6px 9px;
    font-size: 11px;
    line-height: 1;
    border-width: 1px;
    text-box-trim: none;
}

/* Inputs echo .newsletter-input — a single rule under the value, no box.
   Types are enumerated rather than using a bare `input` so checkboxes, radios
   and file inputs keep their native rendering. Add new types here — a type
   that is missing silently falls back to the browser's white box. */
input[type=text],
input[type=number],
input[type=date],
input[type=url],
input[type=password],
input[type=email],
input[type=search],
input[type=tel],
select,
textarea {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 7px 10px;
    height: 34px;
    width: 100%;
    outline: none;
    font-family: var(--f-nhg);
    font-size: 12.5px;
    color: var(--black);
    transition: border-color .15s, box-shadow .15s;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--black);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .06);
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: var(--ink-45);
}

input[type=search]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    height: 12px;
    width: 12px;
    background: var(--ink-45);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 2l8 8M10 2l-8 8' stroke='%23000' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 2l8 8M10 2l-8 8' stroke='%23000' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat;
    cursor: pointer;
}

input::placeholder,
textarea::placeholder {
    color: var(--ink-30);
}

textarea {
    resize: vertical;
    min-height: 74px;
    height: auto;
    line-height: 1.5;
    padding: 9px 11px;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23737373' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    cursor: pointer;
}

label.fld {
    display: block;
    font-family: var(--f-ag-book);
    font-size: var(--t-label);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-60);
    margin-bottom: 5px;
}

.field {
    margin-bottom: 16px;
}

/* ─────────── TABS ─────────── */
/* .nav-link logic: active state reads orange, never underlined */
.tabs {
    max-width: var(--page-max);
    margin: 26px auto 0;
    padding: 0 var(--page-pad) 14px;
    display: flex;
    gap: 26px;
    border-bottom: 2px solid var(--black);
    overflow-x: auto;
}

/* Works as a <button> (in-page panels) or an <a> (navigating away), so the
   anchor defaults are neutralised here — the black wins over the orange `a`
   rule on specificity. */
.tab {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: var(--f-ag-medium);
    font-size: 17px;
    letter-spacing: -.4px;
    text-transform: uppercase;
    color: var(--black);
    text-decoration: none;
    white-space: nowrap;
    transition: color .15s;
}

.tab:hover,
.tab.active {
    color: var(--orange);
}

.panel {
    max-width: var(--page-max);
    margin: 0 auto;
    /* One 16px step of vertical rhythm per panel — cards inside carry no
       margin of their own, so stacked panels read as an even column. */
    padding: 0 var(--page-pad) 16px;
}

.panel[hidden] {
    display: none;
}

/* ─────────── CARDS & SECTIONS ─────────── */
/* Square corners for containers, full-round for buttons — the site's
   own logic (image blocks are hard-edged, pills are 500px). */
.card {
    background: var(--white);
    border: 1px solid var(--rule-soft);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .03), 0 12px 32px -24px rgba(0, 0, 0, .22);
    padding: 24px 26px;
    margin-bottom: 0;
}

.card + .card {
    margin-top: 16px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

h2.sec {
    font-family: var(--f-ag-medium);
    font-size: var(--t-head);
    font-weight: 400;
    letter-spacing: -.2px;
    text-transform: uppercase;
    margin: 0;
}

.sec-note {
    font-size: 12px;
    color: var(--ink-60);
    line-height: 1.55;
    margin: -8px 0 18px;
    max-width: 78ch;
}

.grid2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0 22px;
}

.grid3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0 22px;
}

.empty {
    padding: 38px 20px;
    text-align: center;
    color: var(--ink-45);
    font-size: 12.5px;
    border: 1px dashed var(--rule);
}

/* ─────────── STAT STRIP ─────────── */
/* Rule-over-headline, mirroring .slider-header + .slider-divider */
/* Tools set their own column ratios; even split is the sane default.
   NOTE: a tool that overrides grid-template-columns outside a media query
   must ALSO re-collapse it in its own @media (max-width:820px) block. Media
   queries add no specificity, so the tool's rule beats the narrow rule below
   on source order and the strip would stay multi-column on a phone. */
.stats {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 26px var(--page-pad) 22px;
    display: grid;
    gap: 22px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat {
    border-top: 2px solid var(--black);
    padding-top: 10px;
}

.stat-label {
    font-family: var(--f-ag-book);
    font-size: var(--t-label);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-60);
    margin-bottom: 7px;
}

.stat-val {
    font-family: var(--f-ag-medium);
    font-size: 28px;
    font-weight: 400;
    letter-spacing: -1px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-size: 11.5px;
    color: var(--ink-60);
    margin-top: 6px;
    line-height: 1.35;
}

.ok {
    color: var(--black);
}

.warn {
    color: var(--amber);
}

.bad {
    color: var(--orange);
}

/* ─────────── TABLES ─────────── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--rule-soft);
    background: var(--white);
}

table.tbl {
    border-collapse: collapse;
    width: 100%;
}

table.tbl th {
    font-family: var(--f-ag-book);
    font-size: 10px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-60);
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1.5px solid var(--black);
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 2;
    white-space: nowrap;
}

table.tbl td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--rule-soft);
    vertical-align: middle;
    font-size: 12.5px;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
}

table.tbl tbody tr:last-child td {
    border-bottom: none;
}

table.tbl tbody tr:hover {
    background: rgba(240, 228, 207, .45);
}

/* Right-align numerics — every tool here is mostly numbers. */
table.tbl .r {
    text-align: right;
}

/* ─────────── PILLS & CHIPS ─────────── */
/* .pill is a static badge; .chip is clickable. */
.pill {
    display: inline-block;
    font-family: var(--f-ag-book);
    font-size: 10px;
    line-height: 1.2;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 4px 11px;
    border-radius: 500px;
    border: 1px solid var(--rule);
    color: var(--ink-60);
}

.pill.used {
    color: var(--white);
    background: var(--orange);
    border-color: var(--orange);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.chip {
    font-family: var(--f-ag-book);
    font-size: 10.5px;
    letter-spacing: -.1px;
    text-transform: uppercase;
    padding: 5px 11px;
    border-radius: 500px;
    border: 1px solid var(--black);
    color: var(--black);
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.chip:hover {
    background: var(--orange);
    border-color: var(--orange);
    color: var(--white);
}

/* ─────────── PREFORMATTED OUTPUT ─────────── */
pre.out {
    background: var(--cream);
    border: 1px solid var(--rule);
    padding: 20px;
    overflow: auto;
    max-height: 620px;
    font-family: var(--f-mono);
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--ink-60);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ─────────── TOAST ─────────── */
#toast,
.toast {
    position: fixed;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--black);
    color: var(--cream);
    font-family: var(--f-ag-book);
    font-size: 12px;
    letter-spacing: -.1px;
    text-transform: uppercase;
    padding: 13px 24px;
    border-radius: 500px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 200;
}

#toast.show,
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─────────── NARROW ─────────── */
@media (max-width:820px) {

    .header-inner,
    .stats,
    .tabs,
    .panel,
    .bleed {
        padding-left: var(--page-pad-narrow);
        padding-right: var(--page-pad-narrow);
    }

    .stats {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .tty {
        font-size: 22px;
    }

    .tabs {
        gap: 18px;
    }

    .tab {
        font-size: 15px;
    }
}
