/* neobrutalistcomponents v1.3.0 — theme: riso */
@layer nbc.tokens, nbc.theme, nbc.base, nbc.components, nbc.flourish;

/* tokens.css */
@layer nbc.theme {
/* ============================================================
   RISO — two inks, slightly off.
   A risograph zine: recycled grey stock with grain, navy ink
   for text, fluorescent pink and Riso blue for everything
   loud. Shadows are misregistration — a pink ghost one way, a
   blue plate the other. Archivo pushed to 68% width and 900
   weight for display; IBM Plex Mono for mono.
   Dark: night print — the inks glow on dark stock.
   ============================================================ */
[data-theme="riso"] {
  --nbc-scheme: light;

  --nbc-font-sans: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --nbc-font-display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --nbc-font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --nbc-weight-body: 400;
  --nbc-weight-label: 700;
  --nbc-weight-display: 900;
  --nbc-label-transform: uppercase;
  --nbc-label-spacing: 0.04em;
  --nbc-display-transform: uppercase;
  --nbc-display-spacing: 0em;
  --nbc-display-stretch: 68%;

  --nbc-bg: light-dark(#ebece6, #15141c);
  --nbc-fg: light-dark(#1c2a5a, #f0ece2);
  --nbc-fg-muted: light-dark(#475275, #b4b0c4);
  --nbc-surface: light-dark(#f8f8f3, #1f1e29);
  --nbc-surface-alt: light-dark(#e0e2da, #2a2939);
  --nbc-border-color: light-dark(#1c2a5a, #f0ece2);

  --nbc-primary: light-dark(#ff48b0, #ff6ec0);
  --nbc-primary-fg: #141d40;
  --nbc-accent: light-dark(#0078bf, #49a8ff);
  --nbc-accent-fg: light-dark(#ffffff, #0f1530);

  --nbc-info: light-dark(#0078bf, #49a8ff);
  --nbc-info-fg: light-dark(#ffffff, #0f1530);
  --nbc-success: light-dark(#00a95c, #3ad6a0);
  --nbc-success-fg: #141d40;
  --nbc-warning: #ffe800;
  --nbc-warning-fg: #141d40;
  --nbc-danger: light-dark(#c8173d, #ff7088);
  --nbc-danger-fg: light-dark(#ffffff, #15141c);
  --nbc-focus: light-dark(#0078bf, #49a8ff);

  --nbc-primary-fill: var(--nbc-primary);
  --nbc-danger-fill: var(--nbc-danger);
  --nbc-surface-fill: var(--nbc-surface);
  /* Grain: sparse navy speckle from fractal noise. */
  --nbc-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.16 0 0 0 0 0.35 0 0 0 -2.8 1.15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='0.42'/%3E%3C/svg%3E");

  --nbc-border-width: 2px;
  --nbc-border-style: solid;
  --nbc-radius: 2px;
  --nbc-radius-control: 2px;
  --nbc-radius-button: 2px;
  --nbc-radius-small: 999px;

  /* Misregistration: pink plate slips left, blue plate slips right. */
  --nbc-shadow: -2px 2px 0 light-dark(#ff48b0cc, #ff6ec0cc), 5px 5px 0 var(--nbc-accent);
  --nbc-shadow-lg: -3px 3px 0 light-dark(#ff48b0cc, #ff6ec0cc), 9px 9px 0 var(--nbc-accent);
  --nbc-shadow-press: -1px 1px 0 light-dark(#ff48b0cc, #ff6ec0cc), 2px 2px 0 var(--nbc-accent);
  --nbc-press: 3px;
  --nbc-press-active: 5px;
  --nbc-rotate: 0deg;
  --nbc-focus-width: 3px;
  --nbc-focus-offset: 2px;

  --nbc-duration: 100ms;
  --nbc-duration-slow: 200ms;
  --nbc-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}
}

/* Button.css */
@layer nbc.flourish {
/* Riso: ink sits on grain — the texture prints through solid fills. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-button {
    font-stretch: 88%;
  }

  .nbc-button--primary {
    background: var(--nbc-texture), var(--nbc-primary-fill);
  }

  .nbc-button--danger {
    background: var(--nbc-texture), var(--nbc-danger-fill);
  }
}
}

/* Input.css */
@layer nbc.flourish {
/* Riso: fields are printed on the same grainy stock. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-input {
    background: var(--nbc-texture), var(--nbc-surface);
  }
}
}

/* Card.css */
@layer nbc.flourish {
/* Riso: titles get a highlighter swipe of fluorescent pink ink. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-card__title {
    inline-size: fit-content;
    padding-inline: 0.15em;
    margin-inline: -0.15em;
    background: linear-gradient(
      transparent 52%,
      color-mix(in srgb, var(--nbc-primary) 60%, transparent) 52% 92%,
      transparent 92%
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
}
}

/* Textarea.css */
@layer nbc.flourish {
/* Riso: the textarea is printed on the same grainy stock; selected text gets a
   pink highlighter swipe. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-textarea {
    background: var(--nbc-texture), var(--nbc-surface);
  }

  .nbc-textarea:read-only:not(:disabled) {
    background: var(--nbc-texture), var(--nbc-surface-alt);
  }

  .nbc-textarea::selection {
    background: var(--nbc-primary);
    color: var(--nbc-primary-fg);
  }
}
}

/* Checkbox.css */
@layer nbc.flourish {
/* Riso: the box is printed on the same grain; checked is a pink ink fill with a navy tick
   whose second (blue) ink lands a pixel off. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-checkbox__box {
    border-radius: var(--nbc-radius-control);
    background: var(--nbc-texture), var(--nbc-surface-fill);
  }

  .nbc-checkbox__box:has(.nbc-checkbox__control:checked, .nbc-checkbox__control:indeterminate) {
    background: var(--nbc-texture), var(--nbc-primary-fill);
  }

  .nbc-checkbox__check,
  .nbc-checkbox__dash {
    stroke-width: 4;
    filter: drop-shadow(1px 1px 0 var(--nbc-accent));
  }

  @media (hover: hover) {
    .nbc-checkbox:not(.nbc-checkbox--disabled) .nbc-checkbox__box:has(.nbc-checkbox__control:not(:checked, :indeterminate)):hover {
      background: var(--nbc-texture), var(--nbc-surface-alt);
    }
  }

  @media (forced-colors: active) {
    .nbc-checkbox__box:has(.nbc-checkbox__control:checked, .nbc-checkbox__control:indeterminate) {
      background: Highlight;
    }
  }
}
}

/* Select.css */
@layer nbc.flourish {
/* Riso: the field is printed on the same grainy stock. The chevron is a
   misregistered two-ink print — navy with a pink copy knocked off-register.
   The open list is a grainy sheet; the current value gets the pink swipe. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-select {
    background: var(--nbc-texture), var(--nbc-surface);
  }

  .nbc-select__chevron {
    stroke-width: 3;
    color: var(--nbc-fg);
    filter: drop-shadow(1.5px 1.5px 0 var(--nbc-primary));
  }

  @supports (appearance: base-select) {
    .nbc-select__control::picker(select) {
      background: var(--nbc-texture), var(--nbc-surface-fill);
    }
    .nbc-select__control option {
      font-stretch: 88%;
    }
    .nbc-select__control option:checked:not(:disabled) {
      background: var(--nbc-texture), var(--nbc-primary-fill);
    }
  }
}
}

/* RadioGroup.css */
@layer nbc.flourish {
/* Riso: the dot is printed on the same grain; checked is pink ink with a navy dot, and the
   blue plate lands a hair off as a second ring. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-radio__box {
    background: var(--nbc-texture), var(--nbc-surface-fill);
  }

  .nbc-radio__box:has(.nbc-radio__control:checked) {
    background: var(--nbc-texture), var(--nbc-primary-fill);
  }

  /* Misregistered blue ring: only the checked option gets the second ink. */

  .nbc-radio__box::after {
    content: '';
    position: absolute;
    inset: calc(-1 * var(--nbc-border-width) - 2px);
    border: 2px solid var(--nbc-accent);
    border-radius: 50%;
    opacity: 0;
    scale: 0.8;
    translate: 2px 1px;
    pointer-events: none;
    transition-property: opacity, scale;
    transition-duration: var(--nbc-duration);
    transition-timing-function: var(--nbc-ease);
  }

  .nbc-radio__box:has(.nbc-radio__control:checked)::after {
    opacity: 1;
    scale: 1;
  }

  @media (hover: hover) {
    .nbc-radio:not(.nbc-radio--disabled) .nbc-radio__box:has(.nbc-radio__control:not(:checked)):hover,
    .nbc-radio:not(.nbc-radio--disabled):has(.nbc-radio__label:hover)
      .nbc-radio__box:has(.nbc-radio__control:not(:checked)) {
      background: var(--nbc-texture), var(--nbc-surface-alt);
    }
  }

  @media (forced-colors: active) {
    .nbc-radio__box:has(.nbc-radio__control:checked) {
      background: Canvas;
      border-color: Highlight;
    }
    .nbc-radio__box::after {
      border-color: Highlight;
    }
  }
}
}

/* Badge.css */
@layer nbc.flourish {
/* Riso: a round stamp. Grain prints through the ink, the type is condensed,
   and the pink plate slipped a hair to the left (the primary one is already
   pink, so its ghost plate is blue). */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-badge {
    font-stretch: 85%;
    box-shadow: -2px 1px 0 var(--nbc-primary);
  }

  .nbc-badge--neutral {
    background: var(--nbc-texture), var(--nbc-surface);
  }

  .nbc-badge--primary {
    background: var(--nbc-texture), var(--nbc-primary-fill);
    box-shadow: 2px 1px 0 var(--nbc-accent);
  }

  .nbc-badge--accent {
    background: var(--nbc-texture), var(--nbc-accent);
  }

  .nbc-badge--info {
    background: var(--nbc-texture), var(--nbc-info);
  }

  .nbc-badge--success {
    background: var(--nbc-texture), var(--nbc-success);
  }

  .nbc-badge--warning {
    background: var(--nbc-texture), var(--nbc-warning);
  }

  .nbc-badge--danger {
    background: var(--nbc-texture), var(--nbc-danger-fill);
  }
}
}

/* Switch.css */
@layer nbc.flourish {
/* Riso: the track is printed on the same grain as the page, flooded with pink ink when on.
   The thumb is the second print run: a navy outline with the blue plate landing a hair off. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-switch__track {
    background: var(--nbc-texture), var(--nbc-surface-alt);
  }

  .nbc-switch__track:has(.nbc-switch__control:checked) {
    background: var(--nbc-texture), var(--nbc-primary-fill);
  }

  .nbc-switch__thumb {
    background: var(--nbc-texture), var(--nbc-surface);
    box-shadow: 2px 2px 0 var(--nbc-accent);
  }

  @media (hover: hover) {
    .nbc-switch:not(.nbc-switch--disabled) .nbc-switch__track:has(.nbc-switch__control:not(:checked)):hover {
      background: var(--nbc-texture), color-mix(in srgb, var(--nbc-fg) 12%, var(--nbc-surface-alt));
    }
  }

  @media (forced-colors: active) {
    .nbc-switch__track {
      background: Canvas;
    }
    .nbc-switch__track:has(.nbc-switch__control:checked) {
      background: Highlight;
    }
    .nbc-switch__thumb {
      background: ButtonText;
    }
    .nbc-switch__control:checked ~ .nbc-switch__thumb {
      background: HighlightText;
    }
  }
}
}

/* Alert.css */
@layer nbc.flourish {
/* Riso: two inks, slightly off. A fluorescent pink plate prints over the
   status stripe, shifted down and inward, and titles are stamped in
   condensed uppercase. The grain already comes through --nbc-texture. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-alert::before {
    content: '';
    position: absolute;
    inset-block: 4px -2px;
    inset-inline-start: -3px;
    inline-size: 6px;
    background: color-mix(in srgb, var(--nbc-primary) 85%, transparent);
    pointer-events: none;
  }

  .nbc-alert__title {
    font-family: var(--nbc-font-display);
    font-size: var(--nbc-fs-lg);
    font-weight: var(--nbc-weight-display);
    font-stretch: var(--nbc-display-stretch);
    letter-spacing: var(--nbc-display-spacing);
    line-height: 1.1;
    text-transform: var(--nbc-display-transform);
  }
}
}

/* Progress.css */
@layer nbc.flourish {
/* Riso: two inks on grain. The bar is a flat spot color with the press's
   halftone screen printed over it, and the track picks up the same grain; the
   pink plate slipped left, the blue one right (the shared press shadow). */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-progress__track {
    background: var(--nbc-texture), var(--nbc-surface-alt);
    box-shadow: var(--nbc-shadow-press);
  }

  .nbc-progress__bar {
    background:
      radial-gradient(circle, color-mix(in srgb, var(--nbc-fg) 32%, transparent) 0 1.1px, transparent 1.7px) 0 0 / 5px 5px,
      var(--nbc-texture),
      var(--_bar);
  }

  .nbc-progress__label {
    font-stretch: 85%;
  }

  @media (forced-colors: active) {
    .nbc-progress__bar {
      background: Highlight;
    }
  }
}
}

/* Table.css */
@layer nbc.flourish {
/* Riso: the header is printed in pink ink with grain; the blue plate slipped, so
   its rule starts a few pixels in. Hovered rows get a pale pink swipe. */

@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-table__head {
    background:
      linear-gradient(var(--nbc-accent), var(--nbc-accent)) 5px 100% / 100% 3px no-repeat,
      var(--nbc-texture),
      var(--nbc-primary);
  }

  .nbc-table__head .nbc-table__header-cell {
    font-stretch: 80%;
    color: var(--nbc-primary-fg);
    background: transparent;
    border-block-end-width: 3px;
    border-block-end-color: transparent;
  }

  @media (hover: hover) {
    .nbc-table__body > .nbc-table__row:hover {
      background: color-mix(in srgb, var(--nbc-primary) 20%, transparent);
    }
  }

  @media (forced-colors: active) {
    .nbc-table__head .nbc-table__header-cell {
      border-block-end-color: CanvasText;
    }
  }
}
}

/* Kbd.css */
@layer nbc.flourish {
/* Riso: grainy paper key with a pink bottom edge. */
@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-kbd {
    background: var(--nbc-texture), var(--nbc-surface);
    box-shadow: 0 3px 0 #ff48b0;
  }
}
}

/* Dialog.css */
@layer nbc.flourish {
/* Riso: pink highlighter under the title, misregistered blue ink behind the card. */
@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-dialog {
    box-shadow:
      6px 6px 0 #0078bf,
      -3px -3px 0 color-mix(in srgb, var(--nbc-primary) 70%, transparent);
  }
  .nbc-dialog__title {
    inline-size: fit-content;
    padding-inline: 0.15em;
    margin-inline: -0.15em;
    background: linear-gradient(
      transparent 52%,
      color-mix(in srgb, var(--nbc-primary) 60%, transparent) 52% 92%,
      transparent 92%
    );
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
}
}

/* Tabs.css */
@layer nbc.flourish {
/* Riso: the active tab is printed in pink ink with grain and a misregistered blue edge. */
@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-tabs__tab--active {
    background: var(--nbc-texture), var(--nbc-primary);
    color: var(--nbc-primary-fg);
    border-block-end-color: var(--nbc-border-color);
    box-shadow: 3px 3px 0 var(--nbc-accent);
  }
}
}

/* Tooltip.css */
@layer nbc.flourish {
/* Riso: navy ink on a pink plate, printed slightly off-register. */
@scope ([data-theme="riso"]) to ([data-theme]:not([data-theme="riso"])) {
  .nbc-tooltip {
    color: var(--nbc-primary-fg);
    background: var(--nbc-texture), var(--nbc-primary);
    border-color: var(--nbc-border-color);
    box-shadow: 3px 3px 0 var(--nbc-accent);
  }
}
}
