/* ==========================================================================
   AquaMagis captive portal

   Everything brand-related lives in the :root block below — changing those
   values rebrands the portal without touching anything else.

   No web fonts, no CDN, no external anything: the Apple/Android captive
   mini-browser can only reach hosts in the UniFi walled garden, so an external
   asset would leave the page half-rendered on exactly the devices that matter.
   ========================================================================== */

:root {
    --brand:        #4a8b9b;   /* button + link teal, sampled from the mockup */
    --brand-hover:  #3d7382;
    --brand-active: #35646f;

    --text:         #2b2b2b;
    --text-muted:   #55605f;
    --card-bg:      #ffffff;
    --error:        #b3261e;
    --error-bg:     #fdecea;

    /* Background gradient. Deep pool-water teal, tuned to the logo's #4c8aa2. */
    --bg-from:      #3d8299;
    --bg-mid:       #235c70;
    --bg-to:        #12313f;

    --card-radius:  28px;
    --card-width:   480px;
    --btn-radius:   5px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
            Arial, "Noto Sans", sans-serif;
}

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

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: var(--font);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

/* --------------------------------------------------------------------------
   Background
   -------------------------------------------------------------------------- */

/* A gradient rather than a photo: nothing to download before the guest has
   internet, so the card paints instantly on the walled garden. Edit the --bg-*
   values above to retint it.

   To use a photo instead, add to .backdrop:
       background-image: url('../img/background.jpg');
       background-size: cover;
       background-position: center;
   and keep the file under ~300 KB — it loads before the guest is online. */
.backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-color: var(--bg-mid);
    background-image:
        radial-gradient(125% 95% at 50% 8%, rgba(255, 255, 255, .15), transparent 62%),
        linear-gradient(165deg, var(--bg-from) 0%, var(--bg-mid) 48%, var(--bg-to) 100%);
}

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

.shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    /* Keep the card clear of notches and the iOS home indicator. */
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.card {
    position: relative;
    width: 100%;
    max-width: var(--card-width);
    background: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 22px 40px 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.card--center { padding-top: 40px; text-align: center; }

/* --------------------------------------------------------------------------
   Language switcher
   -------------------------------------------------------------------------- */

.lang {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.lang__icon { flex: none; }

.lang__select {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    padding: 4px 22px 4px 2px;
    cursor: pointer;
    border-radius: 4px;
    /* Chevron drawn inline so no image request is needed. */
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' fill='none' stroke='%23555' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    background-size: 11px 8px;
}

.lang__select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.lang__fallback { display: inline-flex; gap: 10px; font-size: 15px; }
.lang__fallback a { color: var(--brand); }

/* --------------------------------------------------------------------------
   Card content
   -------------------------------------------------------------------------- */

/* The logo carries the branding on its own — there is no visible headline
   beside it — so it runs close to the full inner width of the card. */
.logo {
    display: block;
    width: 100%;
    max-width: 340px;
    max-height: 130px;
    height: auto;
    margin: 14px auto 26px;
}

.title {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    letter-spacing: -.2px;
}

.subtitle {
    margin: 10px 0 0;
    font-size: 17px;
    line-height: 1.4;
    text-align: center;
    color: var(--text-muted);
}

.check { color: var(--brand); margin-bottom: 18px; }

.alert {
    margin: 20px 0 0;
    padding: 11px 14px;
    border-radius: 6px;
    background: var(--error-bg);
    color: var(--error);
    font-size: 14.5px;
    line-height: 1.4;
}

/* Only rendered when 'debug' is on in the config. */
.debug {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 6px;
    background: #2b2b2b;
    color: #f0d9a0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    word-break: break-word;
}

.debug strong { color: #ff9f9f; }

.notice {
    margin: 14px 0 0;
    font-size: 13.5px;
    line-height: 1.4;
    text-align: center;
    color: var(--text-muted);
}

/* Imprint / privacy footer. Required to be reachable before login, so it sits
   on the card itself rather than behind the terms overlay. */
.legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 18px;
    margin: 22px 0 0;
    padding-top: 16px;
    border-top: 1px solid #eaefef;
    font-size: 13px;
}

.legal a {
    color: var(--text-muted);
    text-decoration: none;
}

.legal a:hover { color: var(--brand); text-decoration: underline; }
.legal a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   Consent + button
   -------------------------------------------------------------------------- */

.form { margin-top: 30px; }

.consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 15px;
    line-height: 1.45;
    margin-bottom: 18px;
    cursor: pointer;
}

.consent input[type="checkbox"] {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: var(--brand);
    cursor: pointer;
}

.consent input[type="checkbox"]:disabled { cursor: default; }

/* A button rather than an <a> so opening the terms never navigates away — in a
   captive mini-browser, leaving the page can strand the guest. */
.tos-link {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    color: var(--brand);
    cursor: pointer;
    text-decoration: none;
}

.tos-link:hover { text-decoration: underline; }
.tos-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 11px 18px;
    border: 0;
    border-radius: var(--btn-radius);
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-size: 15.5px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease;
}

.btn:hover:not(:disabled) { background: var(--brand-hover); }
.btn:active:not(:disabled) { background: var(--brand-active); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    box-shadow: inset 0 0 0 1px #d5dbda;
}

.btn--ghost:hover:not(:disabled) { background: #f2f5f5; }
.btn--ghost:active:not(:disabled) { background: #e8eded; }

/* --------------------------------------------------------------------------
   Terms of Service overlay
   -------------------------------------------------------------------------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
}

.modal[hidden] { display: none; }

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
}

.modal__box {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 620px;
    max-height: min(80vh, 720px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    overflow: hidden;
}

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid #e6eaea;
}

.modal__title { margin: 0; font-size: 19px; font-weight: 600; }

.modal__x {
    border: 0;
    background: none;
    font-size: 26px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}

.modal__x:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.modal__body {
    padding: 20px 22px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 14.5px;
    line-height: 1.6;
    color: #333;
}

.modal__body h3 { font-size: 15.5px; margin: 20px 0 6px; }
.modal__body h3:first-child { margin-top: 0; }
.modal__body h4 { font-size: 14.5px; margin: 16px 0 4px; }
.modal__body p  { margin: 0 0 10px; }
.modal__body ul, .modal__body ol { margin: 0 0 10px; padding-left: 20px; }
.modal__body li { margin-bottom: 4px; }
.modal__body a  { color: var(--brand); }

/* Machine-translation notice, shown above terms in any language listed in
   'machine_translated'. */
.modal__note {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0 0 18px;
    padding: 11px 13px;
    border-radius: 7px;
    background: #eef4f6;
    border: 1px solid #d3e1e5;
    color: #3c5b63;
    font-size: 13.5px;
    line-height: 1.45;
}

.modal__note svg { flex: none; margin-top: 1px; }

/* Intro line naming the document. */
.tos-lead {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px !important;
}

.tos-address { padding-left: 2px; line-height: 1.5; }

/* Lettered sub-clauses rendered as a) b) c) to match the German original,
   which numbers them that way rather than with plain bullets. */
.modal__body ol.lit {
    list-style: none;
    padding-left: 2px;
    counter-reset: lit;
}

.modal__body ol.lit > li {
    counter-increment: lit;
    padding-left: 1.7em;
    text-indent: -1.7em;
    margin-bottom: 6px;
}

.modal__body ol.lit > li::before {
    content: counter(lit, lower-alpha) ") ";
    font-variant-numeric: tabular-nums;
}

.modal__foot {
    display: flex;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid #e6eaea;
}

.modal__foot .btn { flex: 1; }

/* --------------------------------------------------------------------------
   Utilities + responsive
   -------------------------------------------------------------------------- */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 520px) {
    .card {
        padding: 20px 24px 30px;
        border-radius: 22px;
    }

    .title { font-size: 25px; }
    .subtitle { font-size: 16px; }
    .logo { max-width: 260px; margin: 8px auto 22px; }
    .modal__box { max-height: 88vh; }
}

/* The mini-browser sheet is short in landscape; let the page scroll rather than
   clipping the button off the bottom. */
@media (max-height: 560px) {
    .shell { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
