/*
 * Reusable component styles ("bricks"). Each class is a self-contained, reusable
 * piece built only from the design tokens in tokens.css. Razor components in
 * Components/ render the markup that uses these classes (AppButton, AppTextField).
 */

/* ---- Auth screen: full-bleed brand gradient, centred content ---- */
.auth-bg {
    min-height: 100vh;
    min-height: 100svh;   /* small-viewport unit: avoids the iOS URL-bar overlap/jump; falls back to vh */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    /* at least 1.5rem, but grow to clear the notch / home indicator where safe-area insets are larger */
    padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right))
             max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
    background: var(--brand-gradient);
    font-family: var(--font-body);
}

/* ---- Frosted-glass card ---- */
.auth-card {
    /* Figma: 371 × 304, radius 24, padding 40/32/32/32, gap 32. Treated as intent, not a
       hard box: max-width keeps it responsive; height comes from the content + padding + gaps
       (≈304) so the 32px bottom padding sits right under the button — no dead space. */
    width: 100%;
    max-width: 371px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;   /* space between welcome text and input (also applies to logo→title, form→error) */
    padding: 40px 32px 32px;
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(7, 51, 44, 0.15);
}

.auth-logo {
    width: 110px;
    height: auto;
    display: block;
}

/* Welcome heading — Figma: Space Grotesk 500 / 16px / centred, in a 226 × 40 box.
   40px tall across two lines = 20px per line → line-height 1.25 (the old 100%/16px was too tight).
   max-width 226px matches the Figma text box; it stays centred via the card's align-items: center. */
.auth-title {
    margin: 0;
    max-width: 226px;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 16px;
    line-height: 1.25;
    letter-spacing: 0;
    color: var(--color-brand-ink);
}

/* Inline form error message, shown inside the card. */
.auth-error {
    margin: 0;
    text-align: center;
    font-family: var(--font-body);
    font-size: 13px;
    color: #b3261e;
}

/* Small underlined link — Helvetica Neue 400 / 12px / underlined / centred. Two contexts:
   .auth-footer-link sits on the dark brand background; .auth-resend-link sits on the light card. */
.auth-footer-link,
.auth-resend-link {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 12px;
    line-height: 100%;
    text-align: center;
    text-decoration: underline;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.auth-footer-link {
    color: rgba(255, 255, 255, 0.92);   /* on the dark brand background */
}

/* "Ikke mottatt kode? Send på nytt" — same link, but on the light card (Base/Text Positive). */
.auth-resend-link {
    color: var(--color-text-positive);
}

.auth-resend-link:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ---- Reusable text field (rendered by Components/AppTextField.razor) ---- */
.app-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 35px;   /* vertical space between stacked controls — e.g. the input and the login button */
    align-items: center;
}

.app-input {
    width: 100%;
    max-width: var(--control-width);
    height: var(--input-height);
    box-sizing: border-box;
    padding: 9px var(--control-pad-x);
    border: 0.75px solid rgba(7, 51, 44, 0.25);
    border-radius: var(--radius-md);
    background: #ffffff;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-brand-ink);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-input::placeholder {
    color: rgba(7, 51, 44, 0.45);
}

.app-input:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(17, 203, 138, 0.25);
}

/* ---- Segmented code input (rendered by Components/AppCodeInput.razor) ----
   A row of equal-width single-character boxes for OTP-style codes. The boxes flex to fill
   the shared control width, so 4/6/8 digits all stay aligned with the inputs and buttons. */
.app-code {
    width: 100%;
    max-width: var(--control-width);
    display: flex;
    gap: 8px;
}

.app-code-box {
    flex: 1 1 0;
    min-width: 0;
    height: 44px;
    box-sizing: border-box;
    padding: 0;
    border: 0.75px solid rgba(7, 51, 44, 0.25);
    border-radius: var(--radius-md);
    background: #ffffff;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 18px;
    color: var(--color-brand);   /* typed digits render in brand green (per Login3) */
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-code-box:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(17, 203, 138, 0.25);
}

/* ---- Reusable button (rendered by Components/AppButton.razor) ---- */
.app-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: var(--control-width);
    height: var(--button-height);
    padding: 0 var(--control-pad-x);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.app-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Tactile press feedback (works for both click and tap; not transitioned, so it feels instant). */
.app-btn:active:not(:disabled) {
    transform: translateY(1px);
}

/* Subtle variant — transparent, 1px muted border + text (the "Logg inn" button).
   Text: Space Grotesk 500 / 14px / line-height 100% / letter-spacing -1%.
   Full `border` shorthand (not just border-color) so it always wins over the base. */
.app-btn--subtle {
    background: transparent;
    border: 1px solid var(--color-text-subtle);
    color: var(--color-text-subtle);
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.01em;
}

.app-btn--subtle:hover:not(:disabled) {
    background: rgba(146, 146, 167, 0.08);
}

/* Solid variant — filled brand button for primary actions elsewhere. */
.app-btn--primary {
    background: var(--color-brand);
    border-color: var(--color-brand);
    color: #ffffff;
}

.app-btn--primary:hover:not(:disabled) {
    background: #0fb87d;
    border-color: #0fb87d;
}

/* Dark variant — solid dark teal (--color-brand-ink), white text. Used for the active
   "Logg inn" on the code screen once all digits are entered (Login3). */
.app-btn--dark {
    background: var(--color-brand-ink);
    border-color: var(--color-brand-ink);
    color: #ffffff;
}

.app-btn--dark:hover:not(:disabled) {
    background: #0a4339;
    border-color: #0a4339;
}

/* ---- Mobile / touch adaptations -----------------------------------------------------
   The login is already a single centred column (mobile-appropriate), so this is not a
   re-layout — it fixes what only bites on phones: touch-target size, the iOS <16px input
   auto-zoom, and cramped width on the smallest screens. Keyed on input method (pointer)
   rather than width, so a touch laptop gets the larger targets too. */
@media (pointer: coarse) {
    /* 16px stops iOS Safari auto-zooming the page on focus; 44px is the min comfortable target. */
    .app-input {
        height: 44px;
        font-size: 16px;
    }

    .app-btn {
        height: 44px;
    }

    /* Give the small secondary links a 44px tap target WITHOUT shifting the tuned spacing:
       padding grows the hit area, the matching negative margin cancels its effect on layout. */
    .auth-footer-link,
    .auth-resend-link {
        padding: 16px 12px;
        margin: -16px -12px;
    }
}

/* Smallest phones (≤360px): reclaim content width by trimming the card's generous padding. */
@media (max-width: 360px) {
    .auth-card {
        padding: 32px 20px 24px;
    }
}
