/* ==========================================================================
   The gate: registration and sign-in for the kingdom.
   A full-bleed view of the capital, with a carved oak plaque over it.
   ========================================================================== */

:root {
    color-scheme: dark;

    --gold:        #d4a44a;
    --gold-light:  #f2d894;
    --gold-deep:   #8b6420;
    --parchment:   #efe3c6;
    --muted:       #ab9a7c;
    --ink:         #0a0805;
    --line:        rgba(196, 152, 74, .38);
    --danger:      #d4674c;

    /* Hammered leather the card is cut from. */
    --card-face: linear-gradient(158deg, rgba(48, 36, 23, .93) 0%, rgba(29, 21, 13, .95) 46%, rgba(17, 12, 8, .96) 100%);

    --corner: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 44'%3E%3Cg fill='none' stroke='%23c99a4a' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M1 43V12C1 5.9 5.9 1 12 1h31'/%3E%3Cpath d='M8 43V15c0-3.9 3.1-7 7-7h28' opacity='.5'/%3E%3C/g%3E%3Cpath d='M12 12l3.4-3.4L18.8 12l-3.4 3.4z' fill='%23e0b55f'/%3E%3C/svg%3E");

    /* Faint fibre so large dark areas do not read as flat digital fill. */
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

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

html, body {
    margin: 0;
    min-height: 100%;
    background: #07060a;
    color: var(--parchment);
    font-family: 'Birzia', 'Segoe UI', Tahoma, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* ==========================================================================
   The scene behind everything: the capital at dusk.
   ========================================================================== */

.gate-scene { position: fixed; inset: 0; overflow: hidden; z-index: 0; }

/* Moved a few pixels by the pointer, so the view has depth instead of being
   a flat wallpaper. The layer is oversized to hide the edges while it moves. */
.gate-parallax {
    position: absolute;
    inset: -4%;
    will-change: transform;
    transition: transform .5s cubic-bezier(.2, .8, .3, 1);
}

.gate-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 42%;
    /* Dusk grade: cooled shadows, warm highlights, pushed back behind the card. */
    filter: saturate(.95) contrast(1.05) brightness(.62);
    transform-origin: 50% 55%;
    animation: gate-breathe 44s ease-in-out infinite alternate;
}

@keyframes gate-breathe {
    from { transform: scale(1.04); }
    to   { transform: scale(1.13) translateY(-1.2%); }
}

body.no-photo .gate-photo { display: none; }

/* Painted stand-in, used when the map image is unavailable. It sits under the
   photo either way, so the first paint is never an empty black screen. */
.gate-painted {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 46% 26% at 50% 84%, rgba(255, 168, 70, .40), transparent 70%),
        radial-gradient(ellipse 84% 36% at 50% 88%, rgba(176, 94, 32, .30), transparent 72%),
        radial-gradient(ellipse 90% 60% at 50% -12%, rgba(64, 90, 124, .34), transparent 70%),
        linear-gradient(180deg, #0b1019 0%, #17131a 42%, #2e1d11 68%, #100b07 88%, #070504 100%);
}

.gate-painted::after {
    content: '';
    position: absolute;
    inset: auto 0 0 0;
    height: 44vh;
    background: linear-gradient(180deg, rgba(58, 40, 24, .9), #0b0906 46%);
    filter: drop-shadow(0 -2px 18px rgba(255, 158, 60, .22));
    clip-path: polygon(0 100%, 0 62%, 9% 62%, 9% 50%, 15% 50%, 15% 62%, 27% 62%, 27% 32%, 34% 32%,
                       34% 22%, 41% 22%, 41% 32%, 59% 32%, 59% 22%, 66% 22%, 66% 32%, 73% 32%,
                       73% 62%, 85% 62%, 85% 50%, 91% 50%, 91% 62%, 100% 62%, 100% 100%);
}

/* Dark corners, so the eye lands on the card and not on the sky. */
.gate-vignette {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 76% 60% at 50% 46%, transparent 0%, rgba(6, 5, 4, .42) 62%, rgba(4, 3, 2, .86) 100%),
        linear-gradient(180deg, rgba(6, 6, 10, .66) 0%, transparent 26%, transparent 58%, rgba(5, 4, 3, .82) 100%);
}

/* Two torch pools washing the scene from the sides. No drawn torch - just the
   light one would throw, which survives any background image. */
.gate-glow {
    position: absolute;
    width: min(46vw, 520px);
    height: min(46vw, 520px);
    border-radius: 50%;
    filter: blur(40px);
    mix-blend-mode: screen;
    pointer-events: none;
}

.gate-glow-a {
    inset-inline-start: -8%;
    top: 18%;
    background: radial-gradient(circle, rgba(255, 168, 72, .30), transparent 68%);
    animation: gate-torch 5.5s ease-in-out infinite;
}

.gate-glow-b {
    inset-inline-end: -10%;
    bottom: 6%;
    background: radial-gradient(circle, rgba(255, 140, 52, .24), transparent 68%);
    animation: gate-torch 7.2s ease-in-out infinite reverse;
}

@keyframes gate-torch {
    0%, 100% { opacity: .85; transform: scale(1); }
    40%      { opacity: .62; transform: scale(1.05); }
    70%      { opacity: 1;   transform: scale(.97); }
}

.gate-grain {
    position: absolute;
    inset: 0;
    background-image: var(--grain);
    opacity: .05;
    mix-blend-mode: overlay;
    pointer-events: none;
}

/* -------------------------------------------------------------- embers -- */

.gate-embers { position: absolute; inset: 0; overflow: hidden; }

.gate-ember {
    position: absolute;
    bottom: -14px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #ffbe5c;
    box-shadow: 0 0 9px 2px rgba(255, 150, 40, .55);
    opacity: 0;
    animation: gate-rise linear infinite;
}

@keyframes gate-rise {
    0%   { opacity: 0; transform: translateY(0) scale(.5); }
    12%  { opacity: .9; }
    100% { opacity: 0; transform: translateY(-100vh) translateX(var(--drift, 0)) scale(1.15); }
}

/* ==========================================================================
   The plaque.
   ========================================================================== */

.gate {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: max(22px, env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
}

.gate-card {
    position: relative;
    width: min(438px, 100%);
    margin-top: clamp(40px, 8vh, 64px);
    display: grid;
    gap: 14px;
    padding: clamp(46px, 7vw, 56px) clamp(20px, 6vw, 32px) clamp(22px, 5vw, 28px);
    text-align: center;
    border-radius: 20px;
    background: var(--card-face);
    border: 1px solid rgba(150, 112, 54, .5);
    box-shadow:
        0 40px 90px rgba(0, 0, 0, .72),
        0 2px 0 rgba(255, 224, 170, .06) inset,
        0 0 0 1px rgba(0, 0, 0, .55);
    backdrop-filter: blur(14px) saturate(1.1);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
    animation: gate-in .62s cubic-bezier(.18, .9, .28, 1.03) both;
}

/* Hairline gold inlay a few pixels inside the edge - the detail that makes the
   panel read as carved rather than as a rounded rectangle. */
.gate-card::before {
    content: '';
    position: absolute;
    inset: 7px;
    border: 1px solid var(--line);
    border-radius: 14px;
    pointer-events: none;
}

.gate-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background-image: var(--grain);
    opacity: .045;
    mix-blend-mode: overlay;
    pointer-events: none;
}

@keyframes gate-in { from { opacity: 0; transform: translateY(26px) scale(.965); } }

/* Filigree in each corner of the inlay. */
.gate-corner {
    position: absolute;
    width: 26px;
    height: 26px;
    background: var(--corner) center / contain no-repeat;
    opacity: .85;
    pointer-events: none;
}

.gate-corner.tl { top: 11px; left: 11px; }
.gate-corner.tr { top: 11px; right: 11px; transform: scaleX(-1); }
.gate-corner.bl { bottom: 11px; left: 11px; transform: scaleY(-1); }
.gate-corner.br { bottom: 11px; right: 11px; transform: scale(-1); }

/* ---------------------------------------------------------- crest seal -- */

.gate-seal {
    position: absolute;
    top: 0;
    left: 50%;
    width: clamp(104px, 26vw, 124px);
    aspect-ratio: 1;
    transform: translate(-50%, -46%);
    display: grid;
    place-items: center;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 34%, rgba(84, 62, 34, .96), rgba(20, 14, 9, .98) 72%);
    border: 1px solid rgba(214, 170, 92, .55);
    box-shadow:
        0 14px 34px rgba(0, 0, 0, .66),
        0 0 34px rgba(255, 168, 70, .18),
        0 1px 0 rgba(255, 226, 170, .16) inset;
}

.gate-seal::before {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    border: 1px solid rgba(196, 152, 74, .3);
}

.gate-crest {
    width: 74%;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, .7));
}

/* ------------------------------------------------------------ headings -- */

.gate-card h1 {
    margin: 0;
    font-size: clamp(23px, 6.4vw, 29px);
    font-weight: 900;
    letter-spacing: .01em;
    line-height: 1.2;
    color: transparent;
    background: linear-gradient(180deg, #fdf0cf 6%, var(--gold-light) 46%, #c08f38 100%);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 0 3px 14px rgba(0, 0, 0, .45);
}

/* A ruled divider with a lozenge in the middle. */
.gate-rule {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin: -4px 0 0;
}

.gate-rule::before,
.gate-rule::after {
    content: '';
    width: clamp(48px, 18vw, 82px);
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.gate-rule i {
    width: 7px;
    height: 7px;
    background: var(--gold);
    transform: rotate(45deg);
    box-shadow: 0 0 10px rgba(212, 164, 74, .5);
}

.gate-lead {
    margin: 0;
    color: var(--muted);
    font-size: clamp(13px, 3.6vw, 14px);
    line-height: 1.6;
}

/* --------------------------------------------------------------- steps -- */

.gate-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 4px 0 2px;
}

.gate-step {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    color: #7d6d55;
    transition: color .28s ease;
}

/* Each step carries its own number on a small seal. */
.gate-step::before {
    content: attr(data-step);
    display: grid;
    place-items: center;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    border: 1px solid rgba(140, 112, 66, .45);
    background: rgba(10, 7, 5, .7);
    color: #8b7856;
    font-size: 11px;
    font-weight: 900;
    transition: all .28s ease;
}

.gate-step.is-active { color: var(--gold-light); }

.gate-step.is-active::before {
    color: #23180a;
    border-color: rgba(240, 208, 128, .9);
    background: linear-gradient(180deg, var(--gold-light), var(--gold));
    box-shadow: 0 0 14px rgba(212, 164, 74, .45);
}

.gate-step.is-done { color: #9db98f; }

.gate-step.is-done::before {
    content: '✓';
    color: #d6ecc9;
    border-color: rgba(140, 176, 128, .55);
    background: rgba(52, 84, 46, .5);
}

.gate-steps i {
    width: clamp(14px, 4vw, 24px);
    height: 1px;
    background: rgba(150, 122, 78, .42);
}

/* --------------------------------------------------------------- forms -- */

.gate-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(8, 6, 4, .35);
}
.gate-tab {
    appearance: none;
    border: 0;
    border-radius: 9px;
    padding: 9px 8px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.gate-tab.is-active {
    background: rgba(212, 164, 74, .18);
    color: var(--gold-light);
    box-shadow: inset 0 0 0 1px rgba(212, 164, 74, .28);
}
.gate-hint {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}

.gate-form { display: grid; gap: 13px; }
.gate-form[hidden] { display: none; }
.gate-form.is-current { animation: gate-step-in .34s ease-out; }

@keyframes gate-step-in { from { opacity: 0; transform: translateX(18px); } }

.gate-field { display: grid; gap: 7px; text-align: right; }

.gate-field > span {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    padding-inline-start: 3px;
    letter-spacing: .02em;
}

.gate-field input {
    width: 100%;
    padding: 15px 16px;
    border: 1px solid rgba(120, 92, 48, .75);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(8, 6, 4, .92), rgba(16, 12, 8, .88));
    color: #fff6e2;
    font: inherit;
    font-size: 16px;          /* keeps iOS from zooming on focus */
    font-weight: 700;
    letter-spacing: .05em;
    outline: none;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, .6);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.gate-field input:focus {
    border-color: var(--gold);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, .55), 0 0 0 3px rgba(212, 164, 74, .2);
}

.gate-field input::placeholder { color: #6b5f4c; font-weight: 400; letter-spacing: normal; }

/* Six separate boxes read as a code, and each one advances on its own. */
.gate-code {
    direction: ltr;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: clamp(6px, 2vw, 9px);
}

.gate-code input {
    width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 64px;
    padding: 0;
    border: 1px solid rgba(120, 92, 48, .75);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(8, 6, 4, .92), rgba(16, 12, 8, .88));
    color: #fff6e2;
    font: inherit;
    font-size: clamp(18px, 5.4vw, 24px);
    font-weight: 900;
    text-align: center;
    outline: none;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, .6);
    transition: border-color .18s ease, box-shadow .18s ease, transform .14s ease;
}

.gate-code input:focus {
    border-color: var(--gold);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, .5), 0 0 0 3px rgba(212, 164, 74, .2);
    transform: translateY(-3px);
}

.gate-code.is-wrong { animation: gate-shake .38s ease-out; }
.gate-code.is-wrong input { border-color: rgba(212, 103, 76, .8); }

@keyframes gate-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-8px); }
    60%      { transform: translateX(7px); }
}

/* -------------------------------------------------------------- button -- */

.gate-btn {
    position: relative;
    overflow: hidden;
    padding: 15px 18px;
    border: 1px solid rgba(244, 210, 138, .6);
    border-radius: 12px;
    background: linear-gradient(180deg, #e2b55d 0%, #b98634 38%, #8a5f1f 100%);
    color: #2a1c07;
    font: inherit;
    font-weight: 900;
    font-size: 16px;
    letter-spacing: .03em;
    text-decoration: none;
    text-shadow: 0 1px 0 rgba(255, 240, 200, .35);
    cursor: pointer;
    box-shadow:
        0 10px 24px rgba(120, 76, 16, .34),
        0 1px 0 rgba(255, 245, 214, .5) inset,
        0 -2px 6px rgba(70, 40, 4, .4) inset;
    transition: filter .16s ease, transform .1s ease, box-shadow .16s ease;
}

/* A slow sheen crossing the metal. */
.gate-btn::after {
    content: '';
    position: absolute;
    top: -60%;
    left: -30%;
    width: 34%;
    height: 220%;
    background: linear-gradient(90deg, transparent, rgba(255, 250, 232, .42), transparent);
    transform: rotate(18deg) translateX(-120%);
    animation: gate-sheen 5.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes gate-sheen {
    0%, 62% { transform: rotate(18deg) translateX(-140%); }
    88%     { transform: rotate(18deg) translateX(460%); }
    100%    { transform: rotate(18deg) translateX(460%); }
}

.gate-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.gate-btn:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 4px 12px rgba(120, 76, 16, .3) inset; }
.gate-btn:disabled { opacity: .6; cursor: progress; }

.gate-google { text-decoration: none; display: block; text-align: center; background: linear-gradient(180deg, #fff 0%, #e9e5dd 100%); color: #332819; border-color: rgba(255,255,255,.8); }
.gate-google span { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-inline-end: 8px; border-radius: 50%; background: #4285f4; color: #fff; font-family: Arial, sans-serif; font-weight: 900; }
.gate-or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: #9d8b6b; font-size: 12px; text-align: center; }
.gate-or::before, .gate-or::after { content: ''; height: 1px; flex: 1; background: rgba(191,154,90,.28); }

.gate-btn.is-busy { color: transparent; text-shadow: none; }
.gate-btn.is-busy::before {
    content: '';
    position: absolute;
    inset: 50% auto auto 50%;
    width: 19px;
    height: 19px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(42, 28, 7, .3);
    border-top-color: #2a1c07;
    border-radius: 50%;
    animation: gate-spin .7s linear infinite;
}

@keyframes gate-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------- small details -- */

.gate-link {
    padding: 6px;
    border: 0;
    background: none;
    color: #c2a163;
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    transition: color .18s ease;
}

.gate-link:hover:not(:disabled) { color: var(--gold-light); }
.gate-link:disabled { color: #6d6250; text-decoration: none; cursor: default; }

.gate-sent { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.65; }
.gate-sent b { color: var(--parchment); direction: ltr; display: inline-block; }

.gate-fine {
    margin: -2px 0 0;
    font-size: 11.5px;
    color: #7a6d58;
    line-height: 1.5;
}

.gate-alert {
    margin: 0;
    padding: 11px 14px;
    border: 1px solid rgba(212, 103, 76, .5);
    border-inline-start: 3px solid var(--danger);
    border-radius: 10px;
    background: rgba(120, 40, 28, .3);
    color: #ffc9ba;
    font-size: 13px;
    line-height: 1.55;
    text-align: right;
    animation: gate-step-in .26s ease-out;
}

.gate-alert.is-info {
    border-color: rgba(140, 176, 128, .45);
    border-inline-start-color: #8fae82;
    background: rgba(52, 84, 46, .28);
    color: #d9efd0;
}

/* Back to the public site, outside the plaque. */
.gate-back { margin: 0; font-size: 13.5px; }

.gate-back a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border: 1px solid rgba(196, 152, 74, .28);
    border-radius: 999px;
    background: rgba(10, 8, 5, .5);
    color: rgba(226, 196, 137, .92);
    text-decoration: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: color .18s ease, border-color .18s ease, background .18s ease;
}

.gate-back a:hover {
    color: var(--gold-light);
    border-color: var(--line);
    background: rgba(30, 22, 14, .65);
}

/* ==========================================================================
   Screens.
   ========================================================================== */

/* Phones: the plaque becomes the app surface, edge to edge. */
@media (max-width: 430px) {
    .gate { gap: 14px; padding-inline: 12px; }
    .gate-card { margin-top: clamp(34px, 7vh, 52px); border-radius: 18px; gap: 12px; }
    .gate-corner { width: 22px; height: 22px; }
    .gate-lead { font-size: 13px; }
    .gate-step { font-size: 11px; gap: 5px; }
    .gate-step::before { width: 19px; height: 19px; font-size: 10px; }
}

/* Short or landscape screens: trim the vertical rhythm so nothing scrolls. */
@media (max-height: 620px) and (orientation: landscape) {
    .gate { align-content: start; padding-top: 12px; }
    .gate-card { margin-top: 42px; padding-top: 40px; gap: 11px; }
    .gate-seal { width: 84px; }
    .gate-card h1 { font-size: 21px; }
    .gate-lead, .gate-fine { display: none; }
    .gate-code input { max-height: 48px; }
}

/* Large screens: a touch more presence, and the scene stays sharper. */
@media (min-width: 1024px) {
    .gate-card { width: 452px; }
    .gate-photo { filter: saturate(.98) contrast(1.04) brightness(.68); }
}

@media (prefers-reduced-motion: reduce) {
    .gate-card, .gate-form.is-current, .gate-alert, .gate-photo,
    .gate-glow, .gate-ember, .gate-btn::after, .gate-code.is-wrong {
        animation: none !important;
    }
    .gate-parallax { transition: none !important; }
}
