/* ==========================================================================
   Hyalith UI. v2.0, 08-Nov-2026. Requires hyalith-tokens.css v2.
   Every component in every state, once. If it is not here and on
   components.html, it does not ship. Components read semantic tokens only,
   so the same class renders on white and inside .ondark.
   ========================================================================== */

/* ---- Base ---- */
.hy, .hy * { box-sizing: border-box; }
.hy { font-family: var(--font); font-size: var(--fs-body); line-height: var(--lh-body); color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased; }
.hy ::selection { background: var(--emerald-100); color: var(--ink); }
.hy :focus { outline: none; }
.hy :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- Type roles. 7. ---- */
.t-display { font-size: var(--fs-display); line-height: var(--lh-display); letter-spacing: var(--ls-display); font-weight: var(--fw-display); color: var(--fg-strong); margin: 0; text-wrap: balance; }
.t-heading { font-size: var(--fs-heading); line-height: var(--lh-heading); letter-spacing: var(--ls-heading); font-weight: var(--fw-heading); color: var(--fg-strong); margin: 0; text-wrap: balance; }
.t-subhead { font-size: var(--fs-subhead); line-height: var(--lh-subhead); letter-spacing: var(--ls-subhead); font-weight: var(--fw-subhead); color: var(--fg-strong); margin: 0; }
.t-lead    { font-size: var(--fs-lead); line-height: var(--lh-lead); margin: 0; text-wrap: pretty; }
.t-body    { font-size: var(--fs-body); line-height: var(--lh-body); margin: 0; text-wrap: pretty; }
.t-small   { font-size: var(--fs-small); line-height: var(--lh-small); margin: 0; }
.t-caption { font-size: var(--fs-caption); line-height: var(--lh-caption); color: var(--fg-2); margin: 0; }
.t-num     { font-variant-numeric: tabular-nums; }

/* Eyebrow: small role, secondary colour. No mono, no caps, no tracking. Citrine only on dark, 1 per view. */
.hy-eyebrow { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--fg-2); margin: 0; }
.ondark .hy-eyebrow--spark { color: var(--spark); }

/* ---- Link ---- */
.hy-link { color: var(--link); text-decoration: underline; text-decoration-color: transparent; text-decoration-thickness: 1px; text-underline-offset: 4px; transition: color var(--t-settle) var(--ease), text-decoration-color var(--t-settle) var(--ease); }
.hy-link:hover { color: var(--link-hover); text-decoration-color: currentColor; }
.hy-link:visited { color: var(--link); }
.ondark .hy-link:hover { color: #FFFFFF; text-decoration-color: var(--spark); }

/* ---- Rule ---- */
.hy-rule { border: 0; border-top: 1px solid var(--line); margin: var(--s-5) 0; }
.hy-rule--spark { border: 0; border-top: 2px solid var(--spark); width: 72px; margin: var(--s-4) 0; }   /* 1 per view */

/* ---- Button ---- */
.hy-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); height: var(--control-h); padding: 0 var(--s-5); font-family: var(--font); font-size: 15px; font-weight: 600; line-height: 1; color: var(--fg); background: transparent; border: 1px solid transparent; border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color var(--t-settle) var(--ease), color var(--t-settle) var(--ease), border-color var(--t-settle) var(--ease); }
.hy-btn:disabled, .hy-btn[aria-disabled="true"] { opacity: 0.4; cursor: default; pointer-events: none; }
.hy-btn--sm { height: var(--control-h-sm); padding: 0 var(--s-4); font-size: 14px; }
.hy-btn--lg { height: var(--control-h-lg); padding: 0 var(--s-6); font-size: 16px; }
.hy-btn--primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.hy-btn--primary:hover, .hy-btn--primary:active { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.hy-btn--secondary { border-color: var(--fg); color: var(--fg); }
.hy-btn--secondary:hover { background: var(--bg-hover); color: var(--fg-strong); }
.hy-btn--secondary:active { background: var(--bg-selected); }
.hy-btn--ghost { color: var(--fg); padding: 0 var(--s-3); }
.hy-btn--ghost:hover { background: var(--bg-hover); color: var(--fg-strong); }
.hy-btn--destructive { background: var(--destructive); border-color: var(--destructive); color: var(--on-destructive); }
.hy-btn--destructive:hover { filter: brightness(0.92); color: var(--on-destructive); }
.hy-btn[aria-busy="true"] { position: relative; color: transparent; pointer-events: none; }
.hy-btn[aria-busy="true"]::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 40%; background: var(--on-primary); animation: hy-busy 1.1s var(--ease) infinite; }
.hy-btn--secondary[aria-busy="true"]::after, .hy-btn--ghost[aria-busy="true"]::after { background: var(--fg); }
@keyframes hy-busy { 0% { left: 0; width: 20%; } 50% { width: 50%; } 100% { left: 80%; width: 20%; } }

/* ---- Nav item. Current page: emerald on light, copper underline on dark. ---- */
.hy-nav { display: flex; align-items: center; gap: var(--s-3) var(--s-5); flex-wrap: wrap; font-size: var(--fs-small); }
.hy-nav a { position: relative; color: var(--fg-2); text-decoration: none; padding-bottom: 2px; transition: color var(--t-settle) var(--ease); }
.hy-nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--primary); transform: scaleX(0); transform-origin: left; transition: transform 280ms var(--ease); }
.hy-nav a:hover { color: var(--fg-strong); }
.hy-nav a:hover::after, .hy-nav a[aria-current="page"]::after { transform: scaleX(1); }
.hy-nav a[aria-current="page"] { color: var(--primary); }
.ondark .hy-nav a::after { background: var(--spark); }
.ondark .hy-nav a[aria-current="page"] { color: #FFFFFF; }
/* a button inside a nav is a button, not a nav link */
.hy-nav a.hy-btn { padding-bottom: 0; }
.hy-nav a.hy-btn::after { display: none; }
.hy-nav a.hy-btn--primary, .hy-nav a.hy-btn--primary:hover { color: var(--on-primary); }
.hy-nav a.hy-btn--secondary, .hy-nav a.hy-btn--ghost { color: var(--fg); }

/* ---- Field ---- */
.hy-field { display: flex; flex-direction: column; gap: var(--s-2); }
.hy-field label, .hy-label { font-size: var(--fs-small); line-height: var(--lh-small); font-weight: 500; color: var(--fg); }
.hy-input { display: block; width: 100%; height: var(--control-h); padding: 0 var(--s-4); font-family: var(--font); font-size: 15px; color: var(--fg); background: transparent; border: 1px solid var(--line-input); border-radius: var(--radius); transition: border-color var(--t-settle) var(--ease); }
textarea.hy-input { height: auto; min-height: 120px; padding: var(--s-3) var(--s-4); line-height: var(--lh-small); resize: vertical; }
select.hy-input { appearance: none; -webkit-appearance: none; padding-right: var(--s-7); background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.hy-input::placeholder { color: var(--fg-3); }
.hy-input:hover { border-color: var(--fg-2); }
.hy-input:focus { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 2px; }
.hy-input:disabled { opacity: 0.4; cursor: default; }
.hy-field .hy-help { font-size: var(--fs-caption); line-height: var(--lh-caption); color: var(--fg-2); }
.hy-field.is-error .hy-input { border-color: var(--status-failed-fg); }
.hy-field.is-error .hy-help { color: var(--status-failed-fg); }
.hy-field.is-error .hy-input:focus { outline-color: var(--status-failed-fg); }

/* ---- Checkbox, radio, switch. On = bottle on light, white on dark. ---- */
.hy-check, .hy-switch { display: inline-flex; align-items: center; gap: var(--s-3); font-size: 15px; cursor: pointer; }
.hy-check input { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; flex: 0 0 auto; border: 1px solid var(--fg-2); border-radius: var(--radius); background: transparent; display: grid; place-content: center; cursor: pointer; transition: background-color var(--t-settle) var(--ease), border-color var(--t-settle) var(--ease); }
.hy-check input[type="radio"] { border-radius: 50%; }
.hy-check input::before { content: ""; width: 10px; height: 10px; transform: scale(0); background: var(--on-primary); transition: transform var(--t-settle) var(--ease); clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
.hy-check input[type="radio"]::before { border-radius: 50%; width: 8px; height: 8px; clip-path: none; }
.hy-check input:checked { background: var(--primary); border-color: var(--primary); }
.hy-check input:checked::before { transform: scale(1); }
.hy-check input:disabled, .hy-check input:disabled + span, .hy-switch input:disabled, .hy-switch input:disabled + span { opacity: 0.4; cursor: default; }
.hy-switch input { appearance: none; -webkit-appearance: none; width: 40px; height: 22px; margin: 0; flex: 0 0 auto; border: 1px solid var(--fg-2); border-radius: var(--radius); background: transparent; position: relative; cursor: pointer; transition: background-color var(--t-settle) var(--ease), border-color var(--t-settle) var(--ease); }
.hy-switch input::before { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; background: var(--fg-2); transition: transform var(--t-settle) var(--ease), background-color var(--t-settle) var(--ease); }
.hy-switch input:checked { background: var(--primary); border-color: var(--primary); }
.hy-switch input:checked::before { transform: translateX(18px); background: var(--on-primary); }

/* ---- Badge, status, dot ---- */
.hy-badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 var(--s-2); font-size: var(--fs-caption); font-weight: 500; line-height: 1; border-radius: var(--radius); white-space: nowrap; background: var(--status-draft-bg); color: var(--status-draft-fg); }
.hy-badge::before { content: ""; width: 6px; height: 6px; background: currentColor; flex: 0 0 auto; }
.hy-badge--live      { background: var(--status-live-bg);    color: var(--status-live-fg); }
.hy-badge--scheduled { background: var(--bg-panel);          color: var(--fg); }
.hy-badge--pending   { background: var(--status-pending-bg); color: var(--status-pending-fg); }
.hy-badge--failed    { background: var(--status-failed-bg);  color: var(--status-failed-fg); }
.hy-badge--draft     { background: var(--status-draft-bg);   color: var(--status-draft-fg); }
.hy-badge--count     { background: var(--status-count-bg);   color: var(--status-count-fg); padding: 0 7px; min-width: 24px; justify-content: center; font-variant-numeric: tabular-nums; }
.hy-badge--count::before { display: none; }
.hy-dot { display: inline-block; width: 8px; height: 8px; background: var(--status-live-fg); vertical-align: middle; }
.hy-dot--alive   { background: var(--spark); }     /* the copper dot: live, now, unread. 1 to 2 per view. */
.hy-dot--info    { background: var(--info); }
.hy-badge--info  { background: var(--info-bg); color: var(--info); }
.hy-dot--pending { background: var(--status-pending-fg); }
.hy-dot--failed  { background: var(--status-failed-fg); }

/* ---- Table ---- */
.hy-table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); line-height: var(--lh-small); }
.hy-table th { text-align: left; font-weight: 500; color: var(--fg-2); padding: 0 var(--s-4) var(--s-3) 0; border-bottom: 1px solid var(--fg); font-size: var(--fs-caption); }
.hy-table td { vertical-align: middle; padding: var(--s-3) var(--s-4) var(--s-3) 0; border-bottom: 1px solid var(--line); }
.hy-table th:last-child, .hy-table td:last-child { padding-right: 0; }
.hy-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hy-table tbody tr:hover td { background: var(--bg-hover); }
.hy-table tbody tr.is-selected td { background: var(--bg-selected); }
.hy-table tbody tr.is-selected td:first-child { box-shadow: inset 2px 0 0 var(--primary); padding-left: 10px; }

/* ---- Card and panel. 3 weights plus the 1 lit surface. ---- */
.hy-card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-5); box-shadow: var(--shadow); transition: border-color var(--t-settle) var(--ease); }
.hy-card--panel { background: var(--bg-panel); border-color: transparent; }
.hy-card--quiet { background: transparent; border-color: var(--line); }
.hy-card--lit   { background: var(--lit); border-color: transparent; color: var(--on-lit); }      /* 1 per screen */
.hy-card--lit .t-subhead, .hy-card--lit .t-heading, .hy-card--lit b { color: var(--on-lit); }
.hy-card--lit .t-caption, .hy-card--lit .hy-eyebrow { color: var(--on-lit-2); }
.hy-card.is-interactive { cursor: pointer; }
.hy-card.is-interactive:hover { border-color: var(--fg-2); }
.hy-card.is-selected { border-color: var(--primary); box-shadow: inset 2px 0 0 var(--primary); }

/* ---- Toast, inline alert. Toast is always green-black, Undo is copper. ---- */
.hy-toast { display: flex; align-items: flex-start; gap: var(--s-3); max-width: 420px; padding: var(--s-4) var(--s-5); background: var(--dark); color: var(--dark-ink); border-radius: var(--radius); font-size: var(--fs-small); line-height: var(--lh-small); }
.ondark .hy-toast { background: var(--dark-3); }
.hy-toast .hy-dot { margin-top: 7px; flex: 0 0 auto; }
.hy-toast strong { color: #FFFFFF; font-weight: 600; display: block; }
.hy-toast .hy-toast-action { margin-left: auto; color: var(--copper-on-dark); font-weight: 600; text-decoration: none; white-space: nowrap; }
.hy-toast .hy-toast-action:hover { text-decoration: underline; text-underline-offset: 4px; }
.hy-alert { display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-left: 2px solid var(--status-live-fg); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--fg); }
.hy-alert .hy-dot { margin-top: 7px; flex: 0 0 auto; }
.hy-alert--pending { border-left-color: var(--status-pending-fg); }
.hy-alert--failed  { border-left-color: var(--status-failed-fg); }
.hy-alert--info    { border-left-color: var(--info); }

/* ---- Chart. Flat, hairline grid, series 1 emerald, series 2 ink blue, 1 copper point. ---- */
.hy-chart { width: 100%; height: auto; display: block; font-family: var(--font); }
.hy-chart .grid  { stroke: var(--chart-grid); stroke-width: 1; }
.hy-chart .axis  { fill: var(--fg-2); font-size: 12px; }
.hy-chart .s1    { fill: none; stroke: var(--chart-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.hy-chart .s2    { fill: none; stroke: var(--chart-2); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.hy-chart .bar   { fill: var(--chart-1); }
.hy-chart .bar2  { fill: var(--chart-2); }
.hy-chart .point { fill: var(--spark); stroke: var(--bg); stroke-width: 2; }
.hy-chart .lbl   { fill: var(--fg-strong); font-size: 13px; font-weight: 600; }
.hy-legend { display: flex; gap: var(--s-4); font-size: var(--fs-caption); color: var(--fg-2); }
.hy-legend span::before { content: ""; display: inline-block; width: 12px; height: 2px; background: var(--chart-1); vertical-align: middle; margin-right: 6px; }
.hy-legend span.s2::before { background: var(--chart-2); }

/* ---- Presentation frame: a product shot on the brand field. Marketing only, never inside a product. ---- */
.hy-shot { position: relative; background: var(--dark); padding: clamp(24px, 6vw, 96px); overflow: hidden; isolation: isolate; }
.hy-shot > .crystal { position: absolute; inset: 0; color: var(--dark-ink); opacity: 0.10; pointer-events: none; z-index: 0; }
.hy-shot > .crystal svg { width: 100%; height: 100%; }
.hy-shot > .screen { position: relative; z-index: 1; border: 1px solid var(--dark-line); }

/* ---- Motion ---- */
.hy-refract { animation: hy-refract var(--t-refract) var(--ease) both; }
@keyframes hy-refract { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.hy-pulse { animation: hy-pulse var(--t-pulse) ease-in-out infinite; }   /* copper dot only */
@keyframes hy-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .hy *, .hy *::before, .hy *::after { animation: none !important; transition: none !important; }
  .hy-refract { opacity: 1; transform: none; }
}
