/* ==========================================================================
   Cheatduck — styles
   ========================================================================== */

:root {
    --paper: #faf9f6;
    --ink: #141413;
    --ink-soft: #4d4c48;
    --ink-muted: #6b6a65;
    --line: rgb(20 20 19 / 0.14);
    --accent: #ffc531;          /* rubber-duck yellow */
    --on-accent: #141413;
    --shadow: rgb(20 20 19 / 0.28);

    --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
    --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

    --gutter: clamp(1.25rem, 4vw, 2.5rem);
    --duck-width: clamp(7.5rem, 26vw, 12rem);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    color-scheme: light;
}

:root[data-theme="dark"] {
    --paper: #0f0f0e;
    --ink: #f3f2ed;
    --ink-soft: #b6b5ae;
    --ink-muted: #8d8c86;
    --line: rgb(243 242 237 / 0.16);
    --shadow: rgb(0 0 0 / 0.6);
    color-scheme: dark;
}

/* No-JS fallback: follow the OS theme. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --paper: #0f0f0e;
        --ink: #f3f2ed;
        --ink-soft: #b6b5ae;
        --ink-muted: #8d8c86;
        --line: rgb(243 242 237 / 0.16);
        --shadow: rgb(0 0 0 / 0.6);
        color-scheme: dark;
    }
}

/* --- Base ---------------------------------------------------------------- */

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

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: var(--paper);
    color: var(--ink);
    font: 400 1rem/1.6 var(--font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.35s ease, color 0.35s ease;
}

::selection {
    background: var(--accent);
    color: var(--on-accent);
}

:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
    border-radius: 6px;
}

button {
    font: inherit;
    color: inherit;
}

p,
h1 {
    margin: 0;
}

/* --- Top bar ------------------------------------------------------------- */

.topbar,
.footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.topbar {
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: 1rem;
}

.brand {
    font: 700 1.125rem/1 var(--font-display);
    letter-spacing: -0.02em;
    color: inherit;
    text-decoration: none;
}

.controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

html:not(.js) .controls {
    display: none;
}

.lang {
    display: flex;
    align-items: center;
    font: 500 0.8125rem/1 var(--font-mono);
    letter-spacing: 0.04em;
}

.lang-btn {
    min-width: 2.25rem;
    min-height: 2.5rem;
    padding: 0 0.25rem;
    border: 0;
    background: none;
    color: var(--ink-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.lang-btn:hover,
.lang-btn[aria-pressed="true"] {
    color: var(--ink);
}

.lang-btn[aria-pressed="true"] {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 3px;
    text-underline-offset: 5px;
}

.lang-sep {
    color: var(--line);
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: none;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.icon-btn:hover {
    border-color: var(--ink);
}

.icon-btn:active {
    transform: scale(0.94);
}

.icon-btn svg {
    width: 1.15rem;
    height: 1.15rem;
}

.theme-sun,
.theme-moon {
    transform-box: fill-box;
    transform-origin: center;
    transition: opacity 0.3s ease, transform 0.45s var(--ease-out);
}

.theme-sun,
:root[data-theme="dark"] .theme-moon {
    opacity: 0;
    transform: rotate(-60deg) scale(0.6);
}

:root[data-theme="dark"] .theme-sun {
    opacity: 1;
    transform: none;
}

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

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 4vh, 3rem) max(var(--gutter), env(safe-area-inset-right)) clamp(2rem, 6vh, 4rem) max(var(--gutter), env(safe-area-inset-left));
    text-align: center;
}

.duck {
    display: block;
    width: var(--duck-width);
    margin: 0 0 clamp(1.25rem, 3.5vh, 2rem);
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.duck:focus-visible {
    outline-offset: 10px;
    border-radius: 50%;
}

.duck-intro,
.duck-bob {
    display: block;
}

.duck-bob {
    transform-origin: 50% 80%;
    animation: bob 7s ease-in-out infinite;
}

.duck-svg {
    display: block;
    width: 100%;
    height: auto;
    transform-origin: 50% 90%;
}

@keyframes bob {
    0%, 50%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-4px) rotate(2deg); }
    75% { transform: translateY(-2px) rotate(-1.5deg); }
}

.eyebrow {
    margin-bottom: 1rem;
    font: 500 0.75rem/1.5 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

@media (max-width: 24rem) {
    .eyebrow {
        font-size: 0.6875rem;
        letter-spacing: 0.04em;
    }
}

.headline {
    max-width: 15ch;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.375rem, 1.35rem + 4.4vw, 4.5rem);
    line-height: 1.02;
    letter-spacing: -0.035em;
    text-wrap: balance;
}

.swash {
    white-space: nowrap;
    padding: 0 0.04em;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 24' preserveAspectRatio='none'%3E%3Cpath d='M4 15C60 7 140 5 205 8s76 6 91 3' fill='none' stroke='%23ffc531' stroke-width='9' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 0 92% / 100% 0.36em;
}

.lede {
    max-width: 34rem;
    margin-top: 1.25rem;
    font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    line-height: 1.6;
    color: var(--ink-soft);
    text-wrap: pretty;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 26rem;
    margin-top: 2rem;
}

.actions .btn:not(:only-child) {
    flex: 1 1 auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 3.25rem;
    padding: 0 1.5rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), border-color 0.2s ease, background-color 0.35s ease, color 0.35s ease;
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn-primary {
    background: var(--ink);
    color: var(--paper);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -12px var(--shadow);
}

.btn-arrow {
    width: 1.15rem;
    height: 1.15rem;
    transition: transform 0.25s var(--ease-out);
}

.btn-primary:hover .btn-arrow {
    transform: translateX(3px);
}

.btn-ghost {
    border: 1.5px solid var(--line);
    color: var(--ink);
}

.btn-ghost:hover {
    border-color: var(--ink);
    transform: translateY(-2px);
}

.btn-icon {
    width: 1.2rem;
    height: 1.2rem;
}

.contact-alt {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.5rem;
    margin-top: 1.25rem;
    font-size: 0.9375rem;
    color: var(--ink-muted);
}

.contact-alt a {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 4px;
    transition: text-decoration-color 0.2s ease;
}

.contact-alt a:hover {
    text-decoration-color: var(--accent);
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 2rem;
    padding: 0 0.6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: none;
    font-size: 0.8125rem;
    color: var(--ink-muted);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.copy-btn:hover {
    color: var(--ink);
    border-color: var(--ink);
}

.copy-btn.is-copied {
    color: var(--ink);
    border-color: var(--accent);
}

.copy-btn svg {
    width: 0.95rem;
    height: 0.95rem;
}

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

.footer {
    padding-top: 1rem;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
    font-size: 0.8125rem;
    color: var(--ink-muted);
}

.konami {
    font: 500 0.75rem/1 var(--font-mono);
    letter-spacing: 0.12em;
    opacity: 0.45;
    transition: opacity 0.3s ease;
    user-select: none;
}

.konami:hover {
    opacity: 1;
}

@media (hover: none), (pointer: coarse) {
    .konami {
        display: none;
    }
}

@media (max-width: 34rem) {
    .footer {
        justify-content: center;
        text-align: center;
    }
}

/* --- Toast & easter egg -------------------------------------------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    z-index: 60;
    max-width: calc(100vw - 2rem);
    padding: 0.75rem 1.1rem;
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font: 500 0.8125rem/1.3 var(--font-mono);
    box-shadow: 0 12px 32px -12px var(--shadow);
    opacity: 0;
    transform: translate(-50%, 1rem);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.4s var(--ease-out);
}

.toast:empty {
    padding: 0;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.duck-rain {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow: hidden;
    pointer-events: none;
}

.duck-rain svg {
    position: absolute;
    top: 0;
    height: auto;
}

/* --- Intro --------------------------------------------------------------- */

/* Hidden until main.js takes over. The 0s animation is a failsafe that
   reveals everything if the script never runs. */
.intro .duck-intro,
.intro [data-reveal] {
    opacity: 0;
}

.i18n-pending [data-i18n],
.i18n-pending [data-i18n-html] {
    visibility: hidden;
}

.intro .duck-intro,
.intro [data-reveal],
.i18n-pending [data-i18n],
.i18n-pending [data-i18n-html] {
    animation: failsafe-show 0s linear 2.5s forwards;
}

@keyframes failsafe-show {
    to { opacity: 1; visibility: visible; }
}

/* Theme switch uses a View Transition when available. */
::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

.theme-switching,
.theme-switching * {
    transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .duck-bob {
        animation: none;
    }
}

/* --- 404 ----------------------------------------------------------------- */

/* The 404 never plays the intro, so .duck-intro's transform is free to use. */
.duck-upside-down .duck-intro {
    transform: rotate(180deg);
}

/* --- Utilities ----------------------------------------------------------- */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    font-size: 16px; /* stops iOS zooming in when the copy fallback focuses it */
}
