/*
 * Shell — shared full-bleed surface for public pages (landing, login, etc.).
 *
 * The body itself is the design canvas: the dark navy frame in dark mode,
 * cream paper in light mode. Pseudo-elements paint the radial brand pops,
 * the grid-line + vignette overlay, and the soft halo glow.
 *
 * Brand colors come from BrandingExtension (--color-*).
 * UI surface tokens come from theme-tokens.css (--frame, --surface, etc.).
 *
 * Page-specific layout (hero, auth-card, etc.) lives in landing.css / login.css.
 */

.shell {
    --shell-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    /* Clip only horizontal decorative bleed. Keeping `overflow: hidden` here
       propagated to the viewport (html is `overflow: visible`) and disabled
       vertical page scrolling when content exceeded the viewport height. */
    overflow-x: hidden;
    margin: 0;
    color: var(--text);
    background: linear-gradient(135deg, var(--frame), var(--frame-2) 54%, var(--frame));
    font-family: var(--shell-font);
    -webkit-font-smoothing: antialiased;
    transition: background 180ms ease, color 180ms ease;
}

.shell::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -4;
    background:
        radial-gradient(ellipse 78% 42% at 50% 101%, color-mix(in srgb, var(--color-secondary) 72%, transparent), transparent 57%),
        radial-gradient(ellipse 54% 38% at 20% 88%, color-mix(in srgb, var(--color-highlight) 34%, transparent), transparent 60%),
        radial-gradient(ellipse 62% 40% at 86% 82%, color-mix(in srgb, var(--color-accent) 34%, transparent), transparent 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 30%);
    opacity: 0.95;
    pointer-events: none;
}

[data-theme="light"] .shell::before {
    background:
        radial-gradient(ellipse 76% 40% at 50% 101%, color-mix(in srgb, var(--color-secondary) 42%, transparent), transparent 58%),
        radial-gradient(ellipse 56% 38% at 19% 88%, color-mix(in srgb, var(--color-highlight) 22%, transparent), transparent 61%),
        radial-gradient(ellipse 62% 42% at 86% 82%, color-mix(in srgb, var(--color-accent) 20%, transparent), transparent 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 32%);
}

.shell::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -3;
    background:
        linear-gradient(90deg, transparent 0, rgba(255, 255, 255, 0.05) 1px, transparent 2px),
        linear-gradient(180deg, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.08) 38%, rgba(0, 0, 0, 0.1));
    background-size: 42px 100%, 100% 100%;
    mask-image: linear-gradient(to bottom, transparent 0, rgba(0, 0, 0, 0.9) 24%, #000 100%);
    pointer-events: none;
}

[data-theme="light"] .shell::after {
    background:
        linear-gradient(90deg, transparent 0, color-mix(in srgb, var(--color-text-primary) 5%, transparent) 1px, transparent 2px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 44%, rgba(255, 255, 255, 0.2));
    background-size: 42px 100%, 100% 100%;
}

.shell__halo {
    position: absolute;
    top: 16%;
    left: 9%;
    right: 9%;
    z-index: -2;
    height: 330px;
    border-radius: 999px;
    background: radial-gradient(closest-side, rgba(255, 255, 255, 0.16), transparent 70%);
    filter: blur(14px);
    opacity: 0.9;
    pointer-events: none;
}

[data-theme="light"] .shell__halo {
    background: radial-gradient(closest-side, color-mix(in srgb, var(--color-primary) 8%, transparent), transparent 70%);
}

.shell__grain {
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0.2;
    background-image:
        linear-gradient(115deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(35deg, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
    background-size: 3px 3px, 5px 5px;
    mix-blend-mode: overlay;
    pointer-events: none;
}

/* Topbar */
.shell__topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 84px;
    padding: 0 clamp(18px, 4vw, 50px);
}

.shell__brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    text-decoration: none;
}

.shell__brand-logo {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.shell__brand-logo-img {
    display: block;
    /* A fixed height, not max-height: an SVG without width/height
       attributes has no intrinsic size and would collapse to 0x0. */
    height: 40px;
    width: auto;
    object-fit: contain;
}

.shell__brand-logo-img--dark {
    display: none;
}

[data-theme="dark"] .shell__brand-logo-img--light {
    display: none;
}

[data-theme="dark"] .shell__brand-logo-img--dark {
    display: block;
}

.shell__brand-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.shell__brand-copy-title {
    overflow: hidden;
    color: var(--text);
    font-size: 15px;
    font-weight: 850;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shell__brand-copy-subtitle {
    color: var(--muted);
    font-size: 11px;
    font-weight: 760;
    letter-spacing: 0.08em;
    line-height: 1.1;
    text-transform: uppercase;
}

.shell__top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shell__contact-link,
.shell__theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.shell__contact-link {
    padding: 0 8px;
    border: 1px solid transparent;
    color: var(--muted);
}

.shell__contact-link:hover {
    color: var(--text-soft);
}

.shell__theme-toggle {
    width: 38px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-soft);
}

.shell__theme-toggle:hover {
    border-color: var(--line-strong);
    background: var(--surface-strong);
    transform: translateY(-1px);
}

.shell__theme-icon-dark,
[data-theme="light"] .shell__theme-icon-light {
    display: none;
}

[data-theme="light"] .shell__theme-icon-dark {
    display: block;
}

/* Focus rings (apply to interactive shell elements) */
.shell__brand:focus-visible,
.shell__contact-link:focus-visible,
.shell__theme-toggle:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

/* Responsive */
@media (max-width: 760px) {
    .shell__topbar {
        min-height: 76px;
        padding-inline: 18px;
    }

    .shell__contact-link {
        display: none;
    }
}

@media (max-width: 460px) {
    .shell__brand-copy-title {
        max-width: 150px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shell,
    .shell *,
    .shell *::before,
    .shell *::after {
        transition: none !important;
    }

    .shell__theme-toggle:hover {
        transform: none;
    }
}

/* Terms & Conditions page — readable card on the public shell. */
.terms__content {
    width: 100%;
    padding: 32px 20px 64px;
    display: flex;
    justify-content: center;
}

.terms__card {
    width: 100%;
    max-width: 880px;
    padding: 36px 40px;
    border-radius: 18px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    color: var(--text);
}

.terms__heading {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.terms__title {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* Body typography — improves readability of long-form HTML content stored
 * in system_preference (paragraphs, lists, headings). Does not change any
 * wording: only spacing, line-height, and color tokens. */
.terms__body {
    color: var(--text-soft);
    font-size: 15px;
    line-height: 1.7;
}

.terms__body > * + * {
    margin-top: 1em;
}

.terms__body h1,
.terms__body h2,
.terms__body h3,
.terms__body h4 {
    color: var(--text);
    font-weight: 700;
    margin-top: 1.6em;
    margin-bottom: 0.5em;
    line-height: 1.3;
}

.terms__body h1 { font-size: 22px; }
.terms__body h2 { font-size: 19px; }
.terms__body h3 { font-size: 17px; }
.terms__body h4 { font-size: 15px; }

.terms__body p {
    margin: 0;
}

.terms__body ul,
.terms__body ol {
    padding-left: 1.4em;
    margin: 0;
}

.terms__body li + li {
    margin-top: 0.4em;
}

.terms__body a {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.terms__body a:hover {
    color: color-mix(in srgb, var(--color-primary) 80%, var(--text));
}

.terms__body strong,
.terms__body b {
    color: var(--text);
    font-weight: 700;
}

.terms__body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.terms__body th,
.terms__body td {
    border: 1px solid var(--line);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}

.terms__body th {
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
}

@media (max-width: 640px) {
    .terms__content {
        padding: 20px 14px 48px;
    }
    .terms__card {
        padding: 24px 20px;
        border-radius: 14px;
    }
    .terms__title {
        font-size: 22px;
    }
    .terms__body {
        font-size: 14.5px;
    }
}
