/* ==========================================================================
   Bad UI Playground — loud, flat, neo-brutalist. The opposite of the portfolio.
   ========================================================================== */

:root {
    --paper: #f4efe6;
    --paper-2: #ebe4d6;
    --ink: #121212;
    --ink-soft: #4a4744;
    --white: #fffdf8;
    --ok: #16a34a;
    --bad: #dc2626;
    --c: #ff5c39;
    --bw: 2.5px;
    --shadow: 5px 5px 0 var(--ink);
    --shadow-sm: 3px 3px 0 var(--ink);
    --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
    --mono: "Space Mono", ui-monospace, Consolas, monospace;
}

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

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

body {
    margin: 0;
    background: var(--paper);
    background-image: radial-gradient(rgba(18, 18, 18, 0.09) 1px, transparent 1px);
    background-size: 22px 22px;
    color: var(--ink);
    font-family: var(--display);
    font-size: 17px;
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }

:focus-visible { outline: 3px solid var(--c); outline-offset: 3px; }

::selection { background: var(--c); color: var(--white); }

/* ---------- Top bar & footer ---------- */

.pg-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px clamp(16px, 4vw, 40px);
    border-bottom: var(--bw) solid var(--ink);
    background: var(--white);
    font-family: var(--mono);
    font-size: 14px;
}

.pg-logo { text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }

.pg-logo__box {
    background: var(--ink);
    color: var(--paper);
    padding: 2px 8px;
    transform: rotate(-4deg);
    display: inline-block;
}

.pg-back { text-decoration: none; border-bottom: 2px solid var(--ink); }
.pg-back:hover { color: var(--c); border-color: var(--c); }

.pg-foot {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 24px;
    padding: 22px clamp(16px, 4vw, 40px);
    border-top: var(--bw) solid var(--ink);
    background: var(--white);
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--ink-soft);
}

/* ---------- Layout ---------- */

.pg-wrap {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: clamp(36px, 7vw, 72px) clamp(16px, 4vw, 40px) 80px;
}

.pg-kicker {
    font-family: var(--mono);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: inline-block;
    background: var(--c);
    color: var(--white);
    padding: 4px 10px;
    border: var(--bw) solid var(--ink);
    box-shadow: var(--shadow-sm);
    transform: rotate(-1.5deg);
    margin-bottom: 26px;
}

.pg-title {
    font-size: clamp(2.6rem, 7.5vw, 5.8rem);
    line-height: 0.95;
    font-weight: 800;
    letter-spacing: -0.035em;
}

.pg-title--sm { font-size: clamp(2.3rem, 6vw, 4.4rem); }

.pg-title__strike {
    position: relative;
    color: var(--c);
    white-space: nowrap;
}

.pg-title__strike::after {
    content: "";
    position: absolute;
    left: -4%;
    right: -4%;
    top: 52%;
    height: 0.12em;
    background: var(--ink);
    transform: rotate(-4deg);
}

.pg-lede { margin-top: 22px; max-width: 60ch; font-size: 1.15rem; color: var(--ink-soft); }

/* ---------- Hub grid ---------- */

.pg-hero { margin-bottom: 56px; }

.pg-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.pg-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    min-height: 230px;
    padding: 22px 22px 20px;
    background: var(--white);
    border: var(--bw) solid var(--ink);
    box-shadow: var(--shadow);
    text-decoration: none;
    transition: transform .15s, box-shadow .15s, background-color .15s;
}

.pg-card:hover { transform: translate(-3px, -3px) rotate(-0.6deg); box-shadow: 9px 9px 0 var(--ink); background: var(--c); color: var(--white); }
.pg-card:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }

.pg-card__num {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 13px;
    align-self: flex-start;
    border: 2px solid currentColor;
    padding: 1px 7px;
}

.pg-card__title { font-size: 1.6rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; margin-top: 8px; }
.pg-card__tag { font-size: 0.98rem; opacity: 0.8; }
.pg-card__credit { margin-top: auto; font-family: var(--mono); font-size: 11.5px; opacity: 0.7; padding-right: 36px; }

.pg-card__go {
    position: absolute;
    right: 16px;
    bottom: 14px;
    font-size: 1.6rem;
    font-weight: 800;
    transition: transform .2s;
}

.pg-card:hover .pg-card__go { transform: translateX(4px); }

/* ---------- Experiment page ---------- */

.pg-exp-head { margin-bottom: 36px; }

.pg-stage {
    position: relative;
    background: var(--white);
    border: var(--bw) solid var(--ink);
    box-shadow: 8px 8px 0 var(--ink);
    padding: clamp(18px, 4vw, 40px);
    min-height: 380px;
}

.pg-howto {
    margin-top: 26px;
    padding: 14px 18px;
    border: var(--bw) dashed var(--ink);
    font-size: 0.98rem;
    background: var(--paper-2);
}

.pg-pager {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: center;
    margin-top: 44px;
}

.pg-pager__link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 12px 16px;
    border: var(--bw) solid var(--ink);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    transition: transform .12s, box-shadow .12s;
}

.pg-pager__link small { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--ink-soft); }
.pg-pager__link--next { text-align: right; }
.pg-pager__link:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.pg-pager__all { font-family: var(--mono); font-size: 13px; }

/* ---------- Shared controls ---------- */

.pg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 18px;
    border: var(--bw) solid var(--ink);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: transform .08s, box-shadow .08s, background-color .15s;
}

.pg-btn:hover { background: var(--paper-2); }
.pg-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.pg-btn--main { background: var(--c); color: var(--white); }
.pg-btn--main:hover { background: var(--ink); }
.pg-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.pg-input {
    width: 100%;
    min-height: 52px;
    padding: 10px 14px;
    border: var(--bw) solid var(--ink);
    background: var(--white);
    box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.08);
    font-family: var(--mono);
    font-size: 1.05rem;
}

.pg-input:focus { outline: none; border-color: var(--c); box-shadow: inset 3px 3px 0 rgba(0,0,0,0.08), 0 0 0 3px var(--c); }

.pg-label { display: block; font-family: var(--mono); font-size: 13px; font-weight: 700; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }

.pg-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.pg-big {
    font-family: var(--mono);
    font-weight: 700;
    font-size: clamp(1.6rem, 5vw, 2.8rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
    word-break: break-word;
}

.pg-note { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }

.pg-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 18px;
    background: var(--paper-2);
    border: var(--bw) solid var(--ink);
    cursor: pointer;
}

.pg-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 30px;
    height: 34px;
    background: var(--c);
    border: var(--bw) solid var(--ink);
    box-shadow: var(--shadow-sm);
    cursor: grab;
}

.pg-range::-moz-range-thumb {
    width: 26px;
    height: 30px;
    border-radius: 0;
    background: var(--c);
    border: var(--bw) solid var(--ink);
    box-shadow: var(--shadow-sm);
    cursor: grab;
}

/* toast */
.pg-toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 100;
    transform: translate(-50%, 140%);
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    background: var(--ink);
    color: var(--paper);
    border: var(--bw) solid var(--ink);
    box-shadow: 5px 5px 0 var(--c);
    font-family: var(--mono);
    font-size: 14px;
    transition: transform .3s cubic-bezier(.2,.9,.3,1.3);
}

.pg-toast.is-on { transform: translate(-50%, 0); }

/* confetti — clipped to the viewport so it never widens the page on mobile */
.pg-confetti-layer {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 90;
    pointer-events: none;
}

.pg-confetti {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 90;
    width: 10px;
    height: 14px;
    border: 1.5px solid var(--ink);
    pointer-events: none;
}

/* success modal */
.pg-win {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(244, 239, 230, 0.92);
    z-index: 5;
    text-align: center;
}

.pg-win[hidden] { display: none; }

.pg-win__card {
    max-width: 520px;
    padding: 28px;
    background: var(--white);
    border: var(--bw) solid var(--ink);
    box-shadow: var(--shadow);
}

.pg-win__card h2 { font-size: 2rem; font-weight: 800; line-height: 1.05; margin-bottom: 10px; }
.pg-win__card p { color: var(--ink-soft); margin-bottom: 18px; }

/* ==========================================================================
   01 Balance Volume
   ========================================================================== */

.vol { display: grid; gap: 18px; justify-items: center; }
.vol canvas { width: 100%; max-width: 760px; aspect-ratio: 2 / 1; touch-action: none; cursor: grab; display: block; }
.vol canvas.is-dragging { cursor: grabbing; }
.vol__readout { display: flex; align-items: center; gap: 14px; }
.vol__meter { width: min(320px, 60vw); height: 22px; border: var(--bw) solid var(--ink); background: var(--paper-2); position: relative; }
.vol__meter span { position: absolute; inset: 0 auto 0 0; background: var(--c); border-right: var(--bw) solid var(--ink); }

/* ==========================================================================
   02 Password Policy
   ========================================================================== */

.pw { display: grid; gap: 20px; max-width: 720px; margin: 0 auto; }
.pw__meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.pw__rules { display: grid; gap: 12px; }

.pw-rule {
    border: var(--bw) solid var(--ink);
    background: #fde8e8;
    box-shadow: var(--shadow-sm);
    animation: ruleIn .35s cubic-bezier(.2,.9,.3,1.3);
}

.pw-rule.is-ok { background: #e3f6e8; }

.pw-rule__head {
    display: flex;
    justify-content: space-between;
    padding: 6px 12px;
    border-bottom: var(--bw) solid var(--ink);
    background: var(--bad);
    color: var(--white);
    font-family: var(--mono);
    font-size: 12.5px;
    font-weight: 700;
}

.pw-rule.is-ok .pw-rule__head { background: var(--ok); }
.pw-rule__body { padding: 12px 14px; font-size: 1.02rem; }

@keyframes ruleIn { from { transform: translateY(-10px) scale(0.97); opacity: 0; } }

/* ==========================================================================
   03 Phone slider
   ========================================================================== */

.phone { display: grid; gap: 26px; max-width: 760px; margin: 0 auto; text-align: center; }
.phone .pg-big { padding: 18px; border: var(--bw) solid var(--ink); background: var(--paper-2); }
.phone .pg-row { justify-content: center; }

/* ==========================================================================
   04 Higher / lower birthday
   ========================================================================== */

.bday { display: grid; gap: 22px; text-align: center; justify-items: center; max-width: 720px; margin: 0 auto; }
.bday__q { font-size: 1.2rem; }
.bday__range { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }
.bday .pg-row { justify-content: center; }

/* ==========================================================================
   05 Scientific date picker
   ========================================================================== */

.sci { display: grid; gap: 22px; max-width: 760px; margin: 0 auto; }
.sci__eq { text-align: center; padding: 20px; border: var(--bw) solid var(--ink); background: var(--ink); color: var(--paper); }
.sci__eq sup { font-size: 0.55em; }
.sci__date { text-align: center; font-size: 1.35rem; font-weight: 700; }
.sci__controls { display: grid; grid-template-columns: auto 1fr 1fr; gap: 18px; align-items: end; }
.sci__sign { min-width: 64px; font-size: 1.4rem; }

/* ==========================================================================
   06 Tabbed keyboard
   ========================================================================== */

.tabkb { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.tabkb > *, .tabkb__deck { min-width: 0; }
.tabkb__out { min-height: 64px; display: flex; align-items: center; font-family: var(--mono); font-size: 1.5rem; padding: 10px 16px; border: var(--bw) solid var(--ink); background: var(--paper-2); word-break: break-all; }
.tabkb__out::after { content: ""; width: 3px; height: 1.3em; background: var(--ink); margin-left: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.tabkb__tabs {
    display: flex;
    gap: 3px;
    overflow-x: auto;
    padding: 8px 4px 0;
    border-bottom: var(--bw) solid var(--ink);
    scrollbar-width: thin;
}

.tabkb__tab {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 8px 7px 12px;
    border: var(--bw) solid var(--ink);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: var(--paper-2);
    font-family: var(--mono);
    font-size: 13px;
    cursor: pointer;
    position: relative;
    top: var(--bw);
}

.tabkb__tab.is-active { background: var(--white); padding-bottom: 9px; z-index: 1; }
.tabkb__x { border: 0; background: none; padding: 0 3px; cursor: pointer; font-size: 13px; line-height: 1; opacity: 0.6; }
.tabkb__x:hover { opacity: 1; color: var(--bad); }

.tabkb__panel { min-height: 200px; display: grid; place-items: center; border: var(--bw) solid var(--ink); border-top: 0; background: var(--white); }

.tabkb__key {
    width: 110px;
    height: 110px;
    border: var(--bw) solid var(--ink);
    background: var(--white);
    box-shadow: 0 7px 0 var(--ink);
    font-family: var(--mono);
    font-size: 2.6rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .06s, box-shadow .06s;
}

.tabkb__key--wide { width: 260px; font-size: 1.2rem; }
.tabkb__key:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--ink); }
.tabkb__key.is-on { background: var(--c); color: var(--white); }

/* ==========================================================================
   07 Catch the login
   ========================================================================== */

.catch { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 24px; }
.catch__form { display: grid; gap: 16px; align-content: start; }
.catch__arena { position: relative; min-height: 320px; border: var(--bw) dashed var(--ink); background: repeating-linear-gradient(45deg, transparent 0 12px, rgba(0,0,0,0.03) 12px 24px); overflow: hidden; touch-action: none; }
.catch__btn { position: absolute; left: 50%; top: 50%; transition: left .22s cubic-bezier(.2,.9,.3,1.2), top .22s cubic-bezier(.2,.9,.3,1.2), transform .2s; white-space: nowrap; }
.catch__btn.is-tired { transition-duration: .7s; }
.catch__status { position: absolute; left: 10px; bottom: 8px; font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }

/* ==========================================================================
   08 Name slot machine
   ========================================================================== */

.slots { display: grid; gap: 24px; justify-items: center; text-align: center; }
.slots__machine { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 18px; background: var(--ink); border: var(--bw) solid var(--ink); box-shadow: var(--shadow); max-width: 100%; }

.reel {
    display: grid;
    gap: 8px;
    justify-items: center;
}

.reel__window {
    width: 64px;
    height: 84px;
    display: grid;
    place-items: center;
    background: var(--white);
    border: var(--bw) solid var(--paper);
    font-family: var(--mono);
    font-size: 2.6rem;
    font-weight: 700;
    overflow: hidden;
    cursor: pointer;
}

.reel.is-spinning .reel__window span { filter: blur(1.2px); animation: roll .08s linear infinite; }
.reel.is-stopped .reel__window { background: var(--c); color: var(--white); }
@keyframes roll { from { transform: translateY(-30%); } to { transform: translateY(30%); } }

.reel__stop { min-height: 32px; padding: 0 10px; font-size: 12px; font-family: var(--mono); }

/* ==========================================================================
   09 Calendar hell
   ========================================================================== */

.cal { display: grid; gap: 22px; max-width: 640px; margin: 0 auto; }
.cal__top { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cal__year { display: flex; align-items: stretch; gap: 8px; }
.cal__year output { flex: 1; display: grid; place-items: center; border: var(--bw) solid var(--ink); font-family: var(--mono); font-weight: 700; font-size: 1.3rem; background: var(--paper-2); }
.cal select.pg-input { cursor: pointer; }

.cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }

.cal__day {
    aspect-ratio: 1;
    border: var(--bw) solid var(--ink);
    background: var(--white);
    font-family: var(--mono);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform .35s cubic-bezier(.2,.9,.3,1.2), background-color .15s;
}

.cal__day:hover { background: var(--paper-2); }
.cal__day.is-picked { background: var(--c); color: var(--white); }
.cal__timer { height: 8px; border: 2px solid var(--ink); background: var(--paper-2); overflow: hidden; }
.cal__timer span { display: block; height: 100%; width: 100%; background: var(--c); transform-origin: left; }
.cal__picked { text-align: center; font-weight: 700; min-height: 1.5em; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .pg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .catch { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .pg-grid { grid-template-columns: 1fr; }
    .pg-pager { grid-template-columns: 1fr 1fr; }
    .pg-pager__all { display: none; }
    .sci__controls { grid-template-columns: 1fr; }
    .cal__top { grid-template-columns: 1fr; }
    .reel__window { width: 48px; height: 66px; font-size: 2rem; }
    .tabkb__key--wide { width: 200px; }
    .pg-back__long { display: none; }
}

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

.pg-input.is-invalid { border-color: var(--bad); background: #fde8e8; animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
