/* Design tokens and base element styling for Raski. */

:root {
    color-scheme: light;

    --bg: #fdfbf7;
    --surface: #ffffff;
    --surface-alt: #f5f1ea;
    --text: #1c1b1a;
    --text-muted: #6b6560;
    --border: #e3ddd3;
    --accent: #ff7a45;
    --accent-contrast: #ffffff;
    --accent-2: #2ec4b6;
    --danger: #d1333f;
    --success: #2f9e44;
    --shadow: 0 2px 8px rgba(28, 27, 26, 0.08);
    --shadow-lg: 0 12px 32px rgba(28, 27, 26, 0.16);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 999px;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
    --header-height: 3.5rem;
    --content-max: 60rem;
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #14161a;
    --surface: #1d2026;
    --surface-alt: #262a32;
    --text: #f2f0ed;
    --text-muted: #a5a29d;
    --border: #333843;
    --accent: #ff8f5e;
    --accent-contrast: #1c1b1a;
    --accent-2: #44e0d0;
    --danger: #ff6b6b;
    --success: #51cf66;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
}

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

html,
body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
    font-size: 1rem;
    line-height: 1.5;
}

/* Installed app: block double-tap zoom but keep pinch-zoom for accessibility.
   Set on every element since touch-action does not carry into nested scroll containers. */
@media (display-mode: standalone) {
    * {
        touch-action: manipulation;
    }
}

h1, h2, h3, h4 {
    margin: 0 0 var(--space-3) 0;
    line-height: 1.2;
    font-weight: 650;
    letter-spacing: -0.01em;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

h1:focus,
h2:focus {
    outline: none;
}

p {
    margin: 0 0 var(--space-3) 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.text-link {
    overflow-wrap: anywhere;
}

:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Visible only while focused, so keyboard users can bypass the header. */
.skip-link {
    position: absolute;
    left: var(--space-3);
    top: -100%;
    z-index: 200;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    box-shadow: var(--shadow);
}

.skip-link:focus-visible {
    top: var(--space-3);
}

main:focus {
    outline: none;
}

/* Layout helpers */

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.row-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spacer {
    flex: 1 1 auto;
}

/* Surfaces */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
    box-shadow: var(--shadow);
}

.card-interactive {
    display: block;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-interactive:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Forms */

label,
.field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

/* Type-agnostic: Blazor's InputText renders an <input> with no type attribute. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):not([type="hidden"]),
select,
textarea {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    min-height: 2.75rem;
    box-shadow: none;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

/* Native date/time pickers ignore appearance and need an explicit reset. */
input[type="date"],
input[type="time"] {
    background-clip: padding-box;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* Custom chevron since the native select arrow does not follow the theme. */
select {
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b6560' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
}

[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a5a29d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}

textarea {
    min-height: 6rem;
    resize: vertical;
}

input:not([type="checkbox"]):not([type="radio"]):hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
    border-color: var(--text-muted);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

input.invalid,
select.invalid,
textarea.invalid,
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: var(--danger);
}

input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--accent);
    flex: 0 0 auto;
}

.field {
    margin-bottom: var(--space-3);
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    padding: 0.55rem 1.1rem;
    min-height: 2.75rem;
    background: var(--surface-alt);
    color: var(--text);
    transition: filter 0.15s ease, transform 0.1s ease;
}

.btn:hover:not(:disabled) {
    filter: brightness(0.96);
    text-decoration: none;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

.btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
}

.btn-secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-icon {
    padding: 0;
    width: 2.75rem;
    min-height: 2.75rem;
    border-radius: var(--radius-pill);
    background: transparent;
    border-color: var(--border);
}

.btn-sm {
    min-height: 2.25rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.875rem;
}

/* Tags and badges */

.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.15rem 0.6rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.tag-accent {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
    color: var(--text);
}

/* Validation */

.valid.modified:not([type=checkbox]) {
    border-color: var(--success);
}

.invalid {
    border-color: var(--danger);
}

.validation-message {
    color: var(--danger);
    font-size: 0.85rem;
}

/* Feedback */

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-6) var(--space-4);
}

.error-banner {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
