/* Patent Loop design system: tokens, base, and the shared shell (header, menu, footer, buttons).
   Direction: sleek and professional, the category standard at full craft. The real product makes the case.
   Palette from the logo: teal #28677d carries actions and state; yellow #ffda76 only for inserted text and
   selection; orange #f39c5e stays in the mark. White and cool-gray fields, one deep ink for dark bands.
   Recorded in DESIGN.md. */

:root {
    /* Logo traces */
    --c-teal: #28677d;
    --c-teal-600: #215869;
    --c-teal-700: #1a4655;
    --c-yellow: #ffda76;
    --c-yellow-soft: #fff3cf;
    --c-orange: #f39c5e;
    --c-orange-hover: #f7b17f;

    /* Neutrals, tinted from the teal */
    --c-ink: #0b1f27;
    --c-ink-2: #475c65;
    --c-ink-3: #7a8d95;           /* non-text marks and large type only */
    --c-paper: #f6f8f9;
    --c-paper-2: #edf2f4;
    --c-white: #ffffff;
    --c-rule: #e1e8eb;
    --c-rule-strong: #c4d0d5;
    --c-teal-50: #eef5f7;
    --c-teal-100: #d9e9ee;

    /* On colored fields */
    --c-on-teal: #ffffff;
    --c-on-teal-2: #d4e8ef;
    --c-on-ink: #f2f6f7;
    --c-on-ink-2: #a3b8bf;
    --c-dark: #0b1f27;
    --c-dark-2: #102a34;

    /* Type */
    --f-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --f-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    --f-mark: "Baumans", var(--f-sans);

    --t-hero: clamp(2.35rem, 1.3rem + 3.6vw, 4.25rem);
    --t-h2: clamp(1.85rem, 1.35rem + 1.7vw, 2.75rem);
    --t-h3: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
    --t-lede: clamp(1.08rem, 1rem + 0.35vw, 1.3rem);
    --t-body: 1rem;
    --t-small: 0.9375rem;
    --t-micro: 0.8125rem;

    /* Space */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-7: 3rem;
    --s-8: 4rem;
    --s-9: 6rem;
    --section-y: clamp(4.5rem, 3rem + 5vw, 8rem);
    --gutter: clamp(1rem, 0.4rem + 2.6vw, 2.5rem);
    --w-max: 78rem;
    --w-text: 68ch;

    /* Edges and depth */
    --r-1: 4px;
    --r-2: 8px;
    --r-3: 12px;
    --sh-1: 0 1px 2px rgba(11, 31, 39, 0.05), 0 4px 12px -4px rgba(11, 31, 39, 0.08);
    --sh-window: 0 1px 2px rgba(11, 31, 39, 0.06), 0 12px 28px -10px rgba(11, 31, 39, 0.16), 0 36px 72px -28px rgba(11, 31, 39, 0.22);
    --sh-doc: 0 2px 6px rgba(11, 31, 39, 0.08), 0 28px 64px -18px rgba(6, 20, 26, 0.45);

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-1: 160ms;
    --dur-2: 420ms;
    --dur-3: 900ms;

    --header-h: 4rem;
    color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 1rem); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
    margin: 0;
    font-family: var(--f-sans);
    font-size: var(--t-body);
    line-height: 1.6;
    color: var(--c-ink);
    background: var(--c-white);
    font-feature-settings: "ss01", "cv11";
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; font-weight: 600; text-wrap: balance; }
p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, video, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
code, kbd { font-family: var(--f-mono); font-size: 0.9em; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Browser surfaces carry the palette too */
::selection { background: var(--c-yellow); color: var(--c-ink); }
:focus-visible { outline: 2px solid var(--c-teal); outline-offset: 3px; border-radius: var(--r-1); }
.on-dark :focus-visible { outline-color: var(--c-yellow); }
html { scrollbar-color: var(--c-rule-strong) var(--c-paper); }
input, textarea { caret-color: var(--c-teal); }

.skip-link {
    position: absolute; left: var(--gutter); top: -4rem; z-index: 200;
    background: var(--c-ink); color: var(--c-on-ink); padding: var(--s-2) var(--s-4);
    font-weight: 600; text-decoration: none; border-radius: var(--r-2);
}
.skip-link:focus { top: var(--s-3); }

.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;
}

/* ---------- Layout primitives ---------- */
.wrap { width: min(100% - 2 * var(--gutter), var(--w-max)); margin-inline: auto; }
.container { width: min(100% - 2 * var(--gutter), var(--w-max)); margin-inline: auto; }


/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.55em;
    min-height: 2.75rem; padding: 0.65rem 1.2rem;
    font-weight: 550; font-size: 0.9375rem; line-height: 1.1; letter-spacing: -0.005em;
    text-decoration: none; border: 1px solid transparent; border-radius: var(--r-2);
    cursor: pointer; white-space: nowrap;
    transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out),
                color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }
.btn-primary {
    background: var(--c-teal); color: var(--c-white);
    box-shadow: 0 1px 2px rgba(11, 31, 39, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn-primary:hover { background: var(--c-teal-600); }
.btn-ghost { background: var(--c-white); color: var(--c-ink); border-color: var(--c-rule-strong); }
.btn-ghost:hover { border-color: var(--c-ink-3); background: var(--c-paper); }
.on-dark .btn-primary { background: var(--c-white); color: var(--c-ink); box-shadow: none; }
.on-dark .btn-primary:hover { background: var(--c-teal-50); }
.on-dark .btn-ghost, .btn-ghost.on-dark { background: transparent; color: var(--c-on-ink); border-color: rgba(255, 255, 255, 0.28); }
.on-dark .btn-ghost:hover, .btn-ghost.on-dark:hover { border-color: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.06); }
.btn-sm { min-height: 2.25rem; padding: 0.45rem 0.9rem; font-size: 0.875rem; }
.btn-lg { min-height: 3rem; padding: 0.75rem 1.4rem; font-size: 1rem; }

.link-arrow {
    display: inline-flex; align-items: center; gap: 0.4em; font-weight: 550; text-decoration: none;
    color: var(--c-teal);
}
.link-arrow svg { width: 1em; height: 1em; transition: transform var(--dur-1) var(--ease-out); }
.link-arrow:hover svg { transform: translateX(3px); }
.link-arrow:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid var(--c-rule);
}
.site-header-inner {
    height: var(--header-h);
    display: flex; align-items: center; gap: var(--s-6);
}
.brand {
    display: inline-flex; align-items: center; gap: 0.6rem;
    text-decoration: none; color: var(--c-teal); flex: none;
}
.brand img { width: 2rem; height: 2rem; }
.brand-name { font-family: var(--f-mark); font-size: 1.35rem; letter-spacing: 0.01em; line-height: 1; }
.brand-name sup { font-family: var(--f-sans); font-size: 0.55em; margin-left: 1px; color: var(--c-ink-2); }
.site-nav { display: flex; align-items: center; gap: var(--s-1); margin-right: auto; }
.site-nav a {
    position: relative; padding: 0.5rem 0.8rem; border-radius: var(--r-2);
    text-decoration: none; font-weight: 500; font-size: 0.9375rem; color: var(--c-ink-2);
    transition: color var(--dur-1) var(--ease-out);
}
.site-nav a:hover { color: var(--c-ink); background: var(--c-paper); }
.site-nav a[aria-current="page"] { color: var(--c-ink); }
.site-nav a[aria-current="page"]::after {
    content: ""; position: absolute; left: 0.8rem; right: 0.8rem; bottom: -0.81rem;
    border-bottom: 2px solid var(--c-teal);
}
.site-actions { display: flex; align-items: center; gap: var(--s-3); }
.menu-toggle {
    display: none; align-items: center; justify-content: center;
    width: 2.75rem; height: 2.75rem; border: 1px solid var(--c-rule-strong); border-radius: var(--r-2);
    background: transparent; cursor: pointer;
}
.menu-toggle svg { width: 1.25rem; height: 1.25rem; }
.menu-toggle .icon-close { display: none; }
.menu-toggle[aria-expanded="true"] .icon-open { display: none; }
.menu-toggle[aria-expanded="true"] .icon-close { display: block; }
.mobile-menu {
    border-top: 1px solid var(--c-rule);
    background: var(--c-white);
    padding: var(--s-4) 0 var(--s-6);
}
.mobile-menu ul { display: grid; }
.mobile-menu li a {
    display: block; padding: 0.9rem 0; text-decoration: none; font-size: 1.125rem; font-weight: 500;
    border-bottom: 1px solid var(--c-rule);
}
.mobile-menu .mobile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: var(--s-5); }

@media (max-width: 1080px) {
    .site-nav, .site-actions .btn-ghost { display: none; }
    .menu-toggle { display: inline-flex; }
    .site-header-inner { justify-content: space-between; }
    .site-actions { margin-left: auto; }
}
@media (max-width: 359px) {
    .site-actions .btn-primary { display: none; }
}

/* ---------- Footer ---------- */
.site-footer { background: var(--c-dark); color: var(--c-on-ink); border-top: 1px solid rgba(255, 255, 255, 0.06); }
.site-footer a { color: var(--c-on-ink-2); text-decoration: none; transition: color var(--dur-1) var(--ease-out); }
.site-footer a:hover { color: var(--c-on-ink); }
.footer-grid {
    display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: var(--s-7);
    padding: var(--s-8) 0 var(--s-7); font-size: var(--t-small);
}
.footer-brand .brand { color: var(--c-on-ink); }
.footer-brand .brand-name sup { color: var(--c-on-ink-2); }
.footer-brand p { margin-top: var(--s-4); color: var(--c-on-ink-2); max-width: 30ch; font-size: var(--t-small); }
.footer-col h2 {
    font-size: 0.875rem; font-weight: 600; letter-spacing: 0;
    color: var(--c-on-ink); margin-bottom: var(--s-4);
}
.footer-col ul { display: grid; gap: 0.6rem; font-size: var(--t-small); }
.footer-col button.footer-link {
    background: none; border: 0; padding: 0; cursor: pointer; color: var(--c-on-ink); font-size: inherit; text-align: left;
}
.footer-col button.footer-link:hover { text-decoration: underline; }
.footer-bottom {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-3);
    padding: var(--s-5) 0 var(--s-6); border-top: 1px solid rgba(169, 196, 204, 0.22);
    font-size: var(--t-micro); color: var(--c-on-ink-2);
}
.footer-bottom a { color: var(--c-on-ink-2); }
@media (max-width: 860px) {
    .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--s-6); }
    .footer-brand { grid-column: 1 / -1; }
}

/* ---------- Usage-guide dialog (shared) ---------- */
.guide-dialog {
    width: min(100% - 2rem, 72rem); height: min(100% - 2rem, 50rem); max-height: none;
    padding: 0; border: 0; border-radius: var(--r-2); background: var(--c-white); color: var(--c-ink);
    box-shadow: var(--sh-doc); overflow: hidden;
}
.guide-dialog::backdrop { background: rgba(8, 28, 36, 0.62); }
.guide-dialog[open] { display: grid; grid-template-rows: auto 1fr; }
.guide-dialog-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
    padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-rule); background: var(--c-paper);
}
.guide-dialog-head h2 { font-size: 1.125rem; }
.guide-close {
    display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem;
    border: 1px solid var(--c-rule-strong); border-radius: var(--r-2); background: var(--c-white); cursor: pointer;
}
.guide-close svg { width: 1.1rem; height: 1.1rem; }
.guide { display: grid; grid-template-columns: 15rem 1fr; min-height: 0; }
.guide-nav { overflow-y: auto; padding: var(--s-4); border-right: 1px solid var(--c-rule); background: var(--c-paper); }
.guide-nav-group + .guide-nav-group { margin-top: var(--s-4); }
.guide-nav-label {
    font-size: 0.8125rem; font-weight: 600; color: var(--c-ink);
    margin: 0 0 var(--s-2) 0.6rem;
}
.guide-tab {
    width: 100%; text-align: left; padding: 0.45rem 0.6rem; border: 0; border-radius: var(--r-2);
    background: transparent; cursor: pointer; font-size: 0.9375rem; color: var(--c-ink-2);
}
.guide-tab:hover { color: var(--c-ink); background: var(--c-paper-2); }
.guide-tab[aria-selected="true"] { color: var(--c-ink); background: var(--c-white); box-shadow: inset 2px 0 0 var(--c-teal); font-weight: 600; }
.guide-panels { overflow-y: auto; min-height: 0; }
.guide-panel { padding: var(--s-6) clamp(1.25rem, 3vw, 3rem) var(--s-8); max-width: 52rem; }
.guide-panel h2 { font-size: 1.75rem; margin-bottom: var(--s-4); }
.guide-panel h3 { font-size: 1.15rem; margin: var(--s-6) 0 var(--s-3); }
.guide-panel h4 { font-size: 1rem; margin: var(--s-5) 0 var(--s-2); }
.guide-panel p + p { margin-top: var(--s-3); }
.guide-panel ul, .guide-panel ol { margin: var(--s-3) 0; padding-left: 1.25rem; display: grid; gap: 0.35rem; }
.guide-panel ul { list-style: disc; }
.guide-panel ol { list-style: decimal; }
.guide-panel ol li p + p { margin-top: 0.15rem; color: var(--c-ink-2); }
.guide-panel dl { display: grid; grid-template-columns: minmax(10rem, 14rem) 1fr; margin: var(--s-4) 0; border-top: 1px solid var(--c-rule); }
.guide-panel dt, .guide-panel dd { margin: 0; padding: 0.7rem 0; border-bottom: 1px solid var(--c-rule); }
.guide-panel dt { font-weight: 600; padding-right: var(--s-4); }
.guide-panel dd { color: var(--c-ink-2); }
.guide-note { margin: var(--s-5) 0; padding: var(--s-4) var(--s-5); background: var(--c-paper); border: 1px solid var(--c-rule); border-radius: var(--r-2); }
.guide-note p + p { margin-top: var(--s-2); }
@media (max-width: 760px) {
    .guide { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .guide-nav { border-right: 0; border-bottom: 1px solid var(--c-rule); max-height: 11rem; }
    .guide-panel dl { grid-template-columns: 1fr; }
    .guide-panel dt { border-bottom: 0; padding-bottom: 0; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
