/*
 * Hand-written styles for the forked SkWebGui components in Components/Ui/.
 * The components emit the same class/data-attribute contract as upstream
 * (sk-btn, sk-form-input, data-color, ...) — this file replaces the Tailwind-
 * compiled sk-web-gui.css with brand styling based on tokens.css.
 *
 * Styled so far (template pattern): Button, Input, Select, FormControl (label/
 * error/helper). Style remaining components (Checkbox, Radio, Alert, Card,
 * Modal, ProgressStepper, Spinner, Divider) the same way as they get used.
 *
 * Accessibility rules for every addition here:
 *  - :focus-visible must produce a clearly visible ring (3:1 contrast).
 *  - Never remove outlines without replacing them.
 *  - Disabled/invalid states must not rely on color alone.
 */

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
    font-family: var(--font-body);
    font-size: var(--font-size-md);
    color: var(--text);
    background: var(--surface-alt);
    min-height: 100%;
    margin: 0;
}

:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}

/* ---------- Button (sk-btn) ---------- */

.sk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    border: 2px solid transparent;
    border-radius: var(--radius-button);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.sk-btn-sm { font-size: var(--font-size-sm); padding: var(--space-1) var(--space-3); min-height: 2rem; }
.sk-btn-md { font-size: var(--font-size-md); padding: var(--space-2) var(--space-4); min-height: 2.75rem; }
.sk-btn-lg { font-size: var(--font-size-lg); padding: var(--space-3) var(--space-6); min-height: 3.25rem; }

.sk-btn-primary {
    background: var(--brand-primary);
    color: var(--brand-on-primary);
}
.sk-btn-primary:hover:not(.sk-btn-disabled) { background: var(--brand-primary-hover); }
.sk-btn-primary:active:not(.sk-btn-disabled),
.sk-btn-primary[data-active="true"] { background: var(--brand-primary-active); }

.sk-btn-secondary {
    background: var(--brand-secondary);
    color: var(--brand-on-secondary);
}
.sk-btn-secondary:hover:not(.sk-btn-disabled) { background: var(--brand-secondary-hover); }

.sk-btn-tertiary,
.sk-btn-ghost {
    background: transparent;
    color: var(--brand-primary);
}
.sk-btn-tertiary:hover:not(.sk-btn-disabled),
.sk-btn-ghost:hover:not(.sk-btn-disabled) { background: var(--surface-alt); }

.sk-btn[data-rounded="true"] { border-radius: var(--radius-pill); }

.sk-btn-disabled,
.sk-btn:disabled {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text-disabled);
    cursor: not-allowed;
}

/* ---------- Input (sk-form-input) ---------- */

.sk-form-input {
    display: block;
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}

.sk-form-input-sm { font-size: var(--font-size-sm); padding: var(--space-1) var(--space-2); min-height: 2rem; }
/* md: 36 px on desktop (WCAG 2.2 target size needs 24 px for mouse use);
   44 px on mobile, where it is a touch target — see the media query below. */
.sk-form-input-md { font-size: var(--font-size-md); padding: var(--space-1) var(--space-3); min-height: 2.25rem; }

@media (max-width: 40rem) {
    .sk-form-input-md { padding: var(--space-2) var(--space-3); min-height: 2.75rem; }
}
.sk-form-input-lg { font-size: var(--font-size-lg); padding: var(--space-3) var(--space-4); min-height: 3.25rem; }

.sk-form-input:hover:not(:disabled) { border-color: var(--brand-primary); }

/* Invalid state: border + the FormErrorMessage text/icon, never color alone */
.sk-form-input[aria-invalid="true"] {
    border-color: var(--error);
    border-width: 2px;
}

.sk-form-input:disabled,
.sk-form-input-disabled {
    background: var(--surface-alt);
    color: var(--text-disabled);
    border-color: var(--border);
    cursor: not-allowed;
}

/* ---------- Select (sk-form-select) ---------- */
/* Same box as Input; the native arrow is kept (high contrast, OS-familiar). */

.sk-form-select {
    display: block;
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--text);
    font-family: inherit;
}

.sk-form-select-sm { font-size: var(--font-size-sm); padding: var(--space-1) var(--space-2); min-height: 2rem; }
/* md: 36 px on desktop, 44 px touch target on mobile — like sk-form-input-md. */
.sk-form-select-md { font-size: var(--font-size-md); padding: var(--space-1) var(--space-3); min-height: 2.25rem; }

@media (max-width: 40rem) {
    .sk-form-select-md { padding: var(--space-2) var(--space-3); min-height: 2.75rem; }
}
.sk-form-select-lg { font-size: var(--font-size-lg); padding: var(--space-3) var(--space-4); min-height: 3.25rem; }

.sk-form-select:hover:not(:disabled) { border-color: var(--brand-primary); }

/* Invalid state: border + the FormErrorMessage text/icon, never color alone */
.sk-form-select[aria-invalid="true"] {
    border-color: var(--error);
    border-width: 2px;
}

.sk-form-select:disabled {
    background-color: var(--surface-alt);
    color: var(--text-disabled);
    border-color: var(--border);
    cursor: not-allowed;
}

/* ---------- FormControl (sk-form-*) ---------- */

.sk-form-control {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    border: 0;
    margin: 0 0 var(--space-4);
    padding: 0;
    min-width: 0;
}

.sk-form-label {
    font-weight: 600;
    color: var(--text);
}

.sk-form-label-sm { font-size: var(--font-size-sm); }
.sk-form-label-md { font-size: var(--font-size-md); }
.sk-form-label-lg { font-size: var(--font-size-lg); }

.sk-form-label-disabled { color: var(--text-disabled); }

.sk-form-required-indicator {
    color: var(--error);
    margin-inline-start: var(--space-1);
}

.sk-form-error-message {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--error);
    font-size: var(--font-size-sm);
}

.sk-form-helper-text {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

/* ---------- Card (sk-card) ---------- */

.sk-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
}

.sk-card[data-color="secondary"] {
    background: var(--brand-secondary);
    color: var(--brand-on-secondary);
    border-color: transparent;
}

.sk-card-body { padding: var(--space-4); }
.sk-card-body-header { font-weight: 600; font-size: var(--font-size-lg); }
.sk-card-body-meta { color: var(--text-muted); font-size: var(--font-size-sm); }

/* ---------- Checkbox (sk-form-checkbox) ----------
   Native input with accent-color — keeps browser accessibility; the
   component's decorative check-icon span is hidden. */

.sk-form-checkbox-label-wrapper {
    display: inline-flex;
    align-items: flex-start;
    gap: var(--space-2);
    cursor: pointer;
}

.sk-form-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0.1rem 0 0;
    accent-color: var(--brand-primary);
    flex-shrink: 0;
    cursor: pointer;
}

.sk-form-checkbox-label-wrapper > .sk-icon { display: none; }

.sk-form-checkbox-disabled,
.sk-form-checkbox:disabled { cursor: not-allowed; }

/* ---------- Radio (sk-form-radio) ---------- */

.sk-form-radio-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.sk-form-radio {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    accent-color: var(--brand-primary);
    flex-shrink: 0;
    cursor: pointer;
}

.sk-form-radio-label[data-disabled="true"] {
    color: var(--text-disabled);
    cursor: not-allowed;
}

/* ---------- ProgressStepper (sk-progress-stepper) ----------
   Styled as the design's bars: number boxes become progress bars, labels
   sit below. Done/current steps get the brand color. */

.sk-progress-stepper {
    display: flex;
    gap: var(--space-3);
}

.sk-progress-stepper-step {
    flex: 1;
    min-width: 0; /* let steps shrink below their label width — labels wrap instead */
}

.sk-progress-stepper-step-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sk-progress-stepper-step-box {
    display: block;
    width: 100%;
    height: 4px;
    border-radius: var(--radius-pill);
    background: var(--border);
    overflow: hidden;
    font-size: 0;             /* hide the step number */
    color: transparent;
}

.sk-progress-stepper-step-box .sk-icon { display: none; }  /* hide the done-checkmark */

.sk-progress-stepper-step[data-progress="current"] .sk-progress-stepper-step-box {
    background: var(--brand-primary);
}

/* Completed steps: lighter brand tint, per design */
.sk-progress-stepper-step[data-progress="done"] .sk-progress-stepper-step-box {
    background: var(--brand-primary);
    opacity: 0.35;
}

.sk-progress-stepper-step-wrapper p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.sk-progress-stepper-step[data-progress="current"] .sk-progress-stepper-step-wrapper p {
    color: var(--text);
    font-weight: 600;
}

.sk-progress-stepper-step-divider { display: none; }  /* gap replaces dividers */

@media (max-width: 40rem) {
    .sk-progress-stepper { gap: var(--space-2); }

    /* Four steps at ~390 px: long words ("Personuppgifter") must hyphenate
       (needs <html lang="sv">) rather than overflow. */
    .sk-progress-stepper-step-wrapper p {
        font-size: 0.75rem;
        white-space: normal;
        hyphens: auto;
        overflow-wrap: anywhere;
    }
}

/* ---------- Divider (sk-divider) ---------- */

.sk-divider {
    border: 0;
    background: var(--border);
    margin: var(--space-6) 0;
}

.sk-divider-horizontal { height: 1px; width: 100%; }
.sk-divider-vertical { width: 1px; align-self: stretch; margin: 0 var(--space-4); }
.sk-divider[data-strong="true"] { background: var(--border-strong); }

/* ---------- Utilities ---------- */

/* Read by screen readers, not shown (e.g. live regions with a visible twin) */
.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;
}

/* ---------- Searchfield (sk-search-field) ---------- */

/* The bordered group plays the input's role; the inner input is borderless. */
.sk-search-field { width: 100%; }

.sk-search-field .sk-form-input-group-inner {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.sk-search-field .sk-form-input-group-inner:hover { border-color: var(--brand-primary); }

.sk-search-field .sk-form-input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
}

/* Focus ring around the whole group (not just the borderless input); the reset
   button keeps its own ring, so only react to the input's focus. */
.sk-search-field .sk-form-input:focus-visible { outline: none; }

.sk-search-field .sk-form-input-group-inner:has(.sk-form-input:focus-visible) {
    outline: var(--focus-ring-width) solid var(--focus-ring);
    outline-offset: var(--focus-ring-offset);
}

.sk-search-field .sk-form-input-addin-left {
    padding-left: var(--space-3);
    color: var(--text-muted);
}

.sk-search-field-icon { width: 1.25rem; height: 1.25rem; }

/* Icon-only reset button: square 44 px touch target */
.sk-search-field-button-reset.sk-btn {
    min-width: 2.75rem;
    padding: 0;
    margin-right: var(--space-1);
}

.sk-search-field-button-reset .sk-icon { width: 1.25rem; height: 1.25rem; }

/* ---------- Icon (sk-icon) ---------- */

.sk-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sk-icon svg { width: 100%; height: 100%; }

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
