/* ==========================================================================
   Base: reset, typography and shared components
   ========================================================================== */

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

/* The hidden attribute always wins over component display rules. */
[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--topbar-height) + var(--space-4));
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg-accent), var(--bg);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern", "liga";
}

img,
svg,
video,
canvas,
iframe {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    font-family: var(--font-display);
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--text);
    text-wrap: balance;
}

h1 {
    font-size: var(--text-3xl);
    font-weight: 750;
}

h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
}

h3 {
    font-size: var(--text-lg);
    font-weight: 650;
    letter-spacing: -0.01em;
}

p {
    margin: 0;
    text-wrap: pretty;
}

a {
    color: var(--brand-text);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration-thickness: 2px;
}

::selection {
    background: var(--selection-bg);
    color: var(--on-gradient);
}

:focus-visible {
    outline: 2px solid var(--brand-strong);
    outline-offset: 3px;
    border-radius: 6px;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sm {
    width: 14px;
    height: 14px;
}

.icon-lg {
    width: 24px;
    height: 24px;
}

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

.skip-link {
    position: fixed;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 100;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-pill);
    background: var(--text);
    color: var(--bg);
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-160%);
    transition: transform var(--fast) var(--ease);
}

.skip-link:focus {
    transform: none;
}

/* --- Small type helpers --------------------------------------------------- */

.pixel {
    font-family: var(--font-pixel);
    letter-spacing: 0.04em;
}

/* Section labels. The pixel font is kept for brand touches only: its V reads as U. */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: var(--text-xs);
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--brand-text);
}

.eyebrow .icon {
    width: 16px;
    height: 16px;
}

.lead {
    font-size: var(--text-lg);
    line-height: 1.65;
    color: var(--text-muted);
    max-width: 62ch;
}

.text-gradient {
    background: var(--brand-gradient-strong);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* --- Buttons --------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0 var(--space-5);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: var(--text-base);
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background-color var(--fast) var(--ease),
        border-color var(--fast) var(--ease);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    color: var(--on-brand);
    background: var(--brand-gradient-strong);
    box-shadow: 0 6px 18px var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 10px 26px var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow-sm);
}

.btn-ghost {
    min-height: 36px;
    padding: 0 var(--space-4);
    color: var(--brand-text);
    background: var(--brand-tint);
}

.btn-ghost:hover {
    background: var(--brand-soft);
}

/* --- Surfaces ------------------------------------------------------------ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 650;
    letter-spacing: 0.02em;
    background: var(--brand-tint);
    color: var(--brand-text);
}

/* --- Page structure -------------------------------------------------------- */

.page-header {
    display: grid;
    gap: var(--space-3);
    margin-bottom: var(--space-7);
}

.page-header .lead {
    margin-top: var(--space-1);
}

.section {
    margin-top: var(--space-8);
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.section-head > div {
    display: grid;
    gap: var(--space-2);
}

.notice {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius-md);
    background: var(--surface-glass);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* --- Shared controls: segmented toggle, tool buttons, toast ------------------------ */

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.segment {
    min-height: 34px;
    padding: 0 var(--space-4);
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 650;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.segment:hover {
    color: var(--text);
    background: var(--brand-tint);
}

.segment.is-active {
    color: var(--on-brand);
    background: var(--brand-gradient-strong);
    box-shadow: 0 4px 12px var(--brand-glow);
}

.tool-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--brand-tint);
    color: var(--brand-text);
    font-size: var(--text-sm);
    font-weight: 650;
    text-decoration: none;
    transition: background-color var(--fast) var(--ease);
}

.tool-button:hover {
    background: var(--brand-soft);
}

/* A small label above a link on hover and keyboard focus, from its data-tip ("Listen on Apple
   Music" on covers). Links without data-tip show nothing. */
.has-tip {
    position: relative;
}

.has-tip[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    z-index: 2;
    padding: 5px 10px;
    border-radius: var(--radius-pill);
    background: var(--text);
    color: var(--surface);
    font-size: var(--text-xs);
    font-weight: 650;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    translate: -50% 4px;
    transition: opacity var(--fast) var(--ease), translate var(--fast) var(--ease);
}

.has-tip[data-tip]:hover::after,
.has-tip[data-tip]:focus-visible::after {
    opacity: 1;
    translate: -50% 0;
}

/* Below instead, where the space above is clipped (the top of a card). */
.has-tip-below[data-tip]::after {
    top: calc(100% + 8px);
    bottom: auto;
    translate: -50% -4px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
    z-index: 200;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-pill);
    background: var(--text);
    color: var(--bg);
    font-size: var(--text-sm);
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transform: translate(-50%, 16px);
    opacity: 0;
    transition: opacity var(--normal) var(--ease), transform var(--normal) var(--ease);
}

.toast.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
}

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