/*
 * Login page (WEB-INF/public/login.jsp): layout, Forgi peeking over the card, the form.
 * The animated planning on the left lives in login-planning.css.
 */

/* Self-hosted (latin subset, SIL Open Font License) so the login page sends nothing to Google. */
@font-face {
    font-family: "Barlow";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/login/barlow-600-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Barlow";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/login/barlow-700-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Open Sans";
    font-style: normal;
    font-weight: 300 800;
    font-stretch: 100%;
    font-display: swap;
    src: url("../fonts/login/open-sans-latin-variable.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --bg: #edf3fa;
    --dot: #c4d3e5;
    --blue-600: #2f83d2;
    --blue-700: #2570b6;
    --blue-800: #164f93;
    --blue-950: #0d2c57;
    --ink: #12233a;
    --ink-soft: #5b6c83;
    --fill: #f1f5fa;
    --danger: #d64545;
    --success: #12a37f;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.5, 0.64, 1);
    --peek: -62%;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

html { overflow-x: hidden; }

body {
    margin: 0;
    font-family: "Open Sans", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.layout {
    min-height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(420px, 1fr);
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: none; }
}

/*
 * Forgi on his own, cut out of logo_new_white_login.png (2761x974).
 * Crop box x 40..812, y 40..960; the clip removes the wordmark's "F" (x >= 770, y < 650).
 * Put a drop-shadow on a PARENT element: on .forgi itself the clip cuts it into a rectangle.
 */
.forgi {
    position: relative;
    aspect-ratio: 772 / 920;
    overflow: hidden;
    clip-path: polygon(0 0, 94.5% 0, 94.5% 66.3%, 100% 66.3%, 100% 100%, 0 100%);
}

.forgi img {
    position: absolute;
    left: -5.181%;
    top: -4.348%;
    width: 357.64%;
    max-width: none;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

/*
 * The white FORGANISER wordmark: crop box x 786..2761, y 334..621 of the same image.
 * (A CSS mask would allow any colour, but masks don't load from file://; to tint it,
 * use an inline SVG filter, see proposal 3.)
 */
.wordmark {
    position: relative;
    display: block;
    aspect-ratio: 1975 / 287;
    overflow: hidden;
}

.wordmark img {
    position: absolute;
    left: -39.797%;
    top: -116.38%;
    width: 139.797%;
    max-width: none;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

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

/* System notification (userNotification); its colours come from the database. */
.sys-banner {
    position: relative;
    z-index: 30;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
    background: #ffd666;
    color: #3d2c00;
}

.sys-banner { animation: banner-in 360ms cubic-bezier(0.16, 1, 0.3, 1); }

@keyframes banner-in {
    from { transform: translateY(-100%); }
    to { transform: none; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

/* ================= Left: brand panel (the planning itself: login-planning.css) ================= */
.brand-panel {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 40px clamp(28px, 5vw, 72px) 48px;
    color: #fff;
    background:
        radial-gradient(80% 60% at 85% 100%, rgba(110, 231, 249, 0.22), transparent 70%),
        linear-gradient(160deg, var(--blue-600) 0%, var(--blue-800) 62%, var(--blue-950) 100%);
}

.brand-panel > .wordmark {
    width: 176px;
    animation: fade-up 700ms var(--ease-out) both;
}

.story {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 24px;
    width: 100%;
    max-width: 640px;
    margin-top: 28px;
}

.tagline {
    margin: 0;
    max-width: 500px;
    font-family: "Barlow", "Open Sans", sans-serif;
    font-size: clamp(24px, 2.3vw, 32px);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.01em;
    animation: fade-up 800ms var(--ease-out) 100ms both;
}

/* ================= Right: Kiekeboe ================= */
.form-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 150px clamp(20px, 4vw, 56px) 100px;
    background: var(--bg);
}

/* Dotted planning paper, fading out towards the edges */
.form-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(var(--dot) 1.2px, transparent 1.6px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(75% 60% at 50% 50%, #000 0%, transparent 100%);
    mask-image: radial-gradient(75% 60% at 50% 50%, #000 0%, transparent 100%);
    pointer-events: none;
}

.langs {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 5;
    display: inline-flex;
    padding: 4px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(13, 44, 87, 0.08);
}

.langs button {
    border: 0;
    background: transparent;
    padding: 6px 11px;
    border-radius: 999px;
    font: 700 12px/1 "Open Sans", sans-serif;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 200ms, color 200ms;
}

.langs button[aria-pressed="true"] { background: var(--blue-600); color: #fff; }
.langs button:not([aria-pressed="true"]):hover { color: var(--ink); background: var(--fill); }
.langs button:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }

.scene {
    position: relative;
    width: 100%;
    max-width: 410px;
}

/* Forgi peeking over the card */
.peek {
    position: absolute;
    left: 50%;
    top: 0;
    z-index: 0;
    width: 150px;
    transform: translate(-50%, var(--peek));
    transition: transform 650ms var(--ease-spring);
}

/* Entrance on the inner element, so .peek's transform stays free for the states below */
.peek .forgi-shadow {
    filter: drop-shadow(0 10px 12px rgba(13, 44, 87, 0.22));
    animation: peek-in 1100ms var(--ease-spring) 650ms both;
}

@keyframes peek-in {
    from { transform: translateY(58%); }
    to { transform: none; }
}

.peek .forgi img {
    transform-origin: 30% 30%;
    animation: bob 4s ease-in-out infinite;
}

@keyframes bob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-2.5%) rotate(1.5deg); }
}

/* Curious while you type your e-mail address */
.scene:has(#email:focus) { --peek: -70%; }
.scene:has(#email:focus) .peek { transform: translate(-50%, var(--peek)) rotate(-5deg); }

/* Polite: he ducks behind the card while you type your password */
.is-pw-focus { --peek: -13%; }

/* Signing in: he rises up and hovers */
.is-loading { --peek: -86%; }
.is-loading .peek .forgi img { animation-duration: 0.9s; }

/* Wrong password: he shakes his head */
.do-shake .peek .forgi img { animation: no 420ms ease-in-out; }

@keyframes no {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-9deg); }
    50% { transform: rotate(8deg); }
    75% { transform: rotate(-5deg); }
}

/* Success: lift-off, while the schedule on the left turns green */
.is-success { --peek: -86%; }

.is-success .peek {
    transform: translate(-50%, calc(var(--peek) - 120vh));
    transition: transform 1100ms cubic-bezier(0.55, 0, 0.8, 0.2) 250ms;
}

.flame {
    position: absolute;
    left: 35%;
    top: 97%;
    width: 22px;
    height: 46px;
    margin-left: -11px;
    border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
    background: radial-gradient(50% 60% at 50% 25%, #ffffff 0%, #b8f5ff 35%, rgba(110, 231, 249, 0.6) 60%, transparent 75%);
    opacity: 0;
    transform: scaleY(0.3);
    transform-origin: top center;
    transition: opacity 200ms, transform 300ms;
}

.is-success .flame {
    opacity: 1;
    transform: scaleY(1);
    animation: flicker 120ms ease-in-out infinite alternate;
}

@keyframes flicker { to { transform: scaleY(1.2) scaleX(0.85); } }

/* Card */
.shake-wrap { position: relative; z-index: 1; }

.do-shake .shake-wrap { animation: shake 420ms ease-in-out; }

.card {
    position: relative;
    padding: 34px 34px 30px;
    border-radius: 26px;
    background: #fff;
    box-shadow:
        0 1px 2px rgba(13, 44, 87, 0.06),
        0 20px 50px -18px rgba(13, 44, 87, 0.25);
    animation: fade-up 700ms var(--ease-out) 200ms both;
}

h1 {
    margin: 0;
    text-align: center;
    font-family: "Barlow", "Open Sans", sans-serif;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.subtitle {
    margin: 6px 0 26px;
    text-align: center;
    color: var(--ink-soft);
    font-size: 14.5px;
}

.field { margin-bottom: 16px; }

.field label {
    display: block;
    margin: 0 0 7px 2px;
    font-size: 13px;
    font-weight: 600;
}

.control { position: relative; }

.control input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 1.5px solid transparent;
    border-radius: 14px;
    background: var(--fill);
    font: 500 15px "Open Sans", sans-serif;
    color: var(--ink);
    transition: background 180ms, border-color 180ms, box-shadow 180ms;
}

.control input:hover { background: #e9f0f8; }

.control input:focus {
    outline: none;
    background: #fff;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 4px rgba(47, 131, 210, 0.15);
}

.field-invalid .control input { border-color: var(--danger); background: #fff; }

#password { padding-right: 80px; }

.reveal {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    padding: 8px 10px;
    border-radius: 9px;
    font: 600 12.5px "Open Sans", sans-serif;
    color: var(--blue-600);
    cursor: pointer;
}

.reveal:hover { background: #e6f0fa; }
.reveal:focus-visible { outline: 2px solid var(--blue-600); }

.field-error {
    margin: 6px 2px 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--danger);
}

.field-error:empty { display: none; }

.caps {
    display: none;
    margin: 6px 2px 0;
    font-size: 12.5px;
    font-weight: 600;
    color: #a86a00;
}

.caps-on.is-pw-focus .caps { display: block; }

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 24px;
    font-size: 14px;
}

.check-label { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }

.check-label input {
    appearance: none;
    width: 20px;
    height: 20px;
    margin: 0;
    border-radius: 50%;
    border: 1.5px solid #b5c5d8;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: border-color 160ms;
}

.check-label input::after {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--blue-600);
    transform: scale(0);
    transition: transform 260ms var(--ease-spring);
}

.check-label input:checked { border-color: var(--blue-600); }
.check-label input:checked::after { transform: scale(1); }
.check-label input:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }

.row a { color: var(--blue-600); font-weight: 600; text-decoration: none; }
.row a:hover { text-decoration: underline; }

.form-error {
    margin: -8px 0 16px;
    padding: 11px 14px;
    border-radius: 12px;
    background: #fdeeee;
    color: #8f1f1f;
    font-size: 13.5px;
    font-weight: 600;
    text-align: center;
    animation: fade-up 280ms var(--ease-out);
}

.form-error[hidden] { display: none; }

.submit {
    position: relative;
    width: 100%;
    height: 54px;
    border: 0;
    border-radius: 999px;
    background: var(--blue-600);
    color: #fff;
    font: 700 16px "Open Sans", sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    overflow: hidden;
    isolation: isolate;
    box-shadow: 0 12px 24px -12px rgba(47, 131, 210, 0.95);
    transition: background 250ms, transform 160ms var(--ease-out);
}

.submit:hover:not(:disabled) { background: var(--blue-700); }
.submit:active:not(:disabled) { transform: scale(0.985); }
.submit:focus-visible { outline: 3px solid var(--blue-950); outline-offset: 3px; }
.submit:disabled { cursor: progress; }

/* Loading: a light band sweeps through the button */
.submit::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.28) 50%, transparent 80%);
    transform: translateX(-100%);
}

.is-loading .submit::before { animation: sheen 1.1s ease-in-out infinite; }

@keyframes sheen { to { transform: translateX(100%); } }

.dots { display: none; gap: 4px; }

.dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: dot 900ms ease-in-out infinite;
}

.dots i:nth-child(2) { animation-delay: 120ms; }
.dots i:nth-child(3) { animation-delay: 240ms; }

@keyframes dot {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-5px); opacity: 1; }
}

.is-loading .dots { display: inline-flex; }

.is-success .submit { background: var(--success); box-shadow: 0 12px 24px -12px rgba(18, 163, 127, 0.95); }

.help {
    position: relative;
    margin: 24px 0 0;
    text-align: center;
    font-size: 13.5px;
    color: var(--ink-soft);
}

.help a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }

/* Superadmin login (WEB-INF/admin/login.jsp): marks the page so nobody mistakes it for the normal login */
.admin-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    width: max-content;
    margin: 0 auto 14px;
    padding: 5px 12px 5px 9px;
    border-radius: 999px;
    background: var(--blue-950);
    color: #fff;
    font: 700 11.5px/1 "Open Sans", sans-serif;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.admin-badge svg { width: 13px; height: 13px; color: #6ee7f9; }

/* Subscription almost expired: the user is signed in and confirms before going on */
.notice {
    margin: -8px 0 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff4d9;
    color: #5c4300;
    font-size: 13.5px;
    font-weight: 600;
    text-align: center;
}

.notice[hidden] { display: none; }

.notice button {
    margin-top: 10px;
    padding: 8px 18px;
    border: 0;
    border-radius: 999px;
    background: var(--blue-600);
    color: #fff;
    font: 700 13.5px "Open Sans", sans-serif;
    cursor: pointer;
}

.notice button:focus-visible { outline: 3px solid var(--blue-950); outline-offset: 2px; }

/* ================= Small screens: the planning becomes a header band ================= */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .brand-panel { padding: 20px 16px; }
    .brand-panel > .wordmark { width: 140px; }
    .story { margin-top: 14px; gap: 0; max-width: none; }
    .tagline { display: none; }
    .form-panel { justify-content: flex-start; padding: 130px 16px 48px; }
    .langs { top: 14px; right: 14px; }
    .peek { width: 122px; }
    .card { padding: 28px 20px 24px; border-radius: 22px; }
    .control input { font-size: 16px; } /* below 16px iOS zooms in on focus */
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: 1ms !important;
    }
    .is-success .peek { transform: translate(-50%, var(--peek)); }
}
