/* DIGIGMA design system — primitives.
   Scoped to .ds-root. Live home imports this file. Other live pages do not. */

.ds-root {
  box-sizing: border-box;
  min-height: 100%;
  background-color: var(--paper);
  background-image: url("/brand/digits.svg?v=851a8c2ad02a7c5abcc0b0619c547ae99aa57c00"), url("/brand/seigaiha.svg?v=851a8c2ad02a7c5abcc0b0619c547ae99aa57c00");
  background-repeat: repeat, repeat;
  background-size: var(--motif-digits-size, 900px 640px), 168px 84px;
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.ds-root[data-ds-theme="dark"],
[data-ds-theme="dark"].ds-root {
  background-image: url("/brand/digits-dark.svg?v=851a8c2ad02a7c5abcc0b0619c547ae99aa57c00"), url("/brand/seigaiha.svg?v=851a8c2ad02a7c5abcc0b0619c547ae99aa57c00");
}

@media (max-width: 760px) {
  .ds-root {
    background-size: var(--motif-digits-size-compact, 1100px 780px), 168px 84px;
  }
}

.ds-root [hidden] { display: none !important; }

.ds-root h1,
.ds-root h2,
.ds-root h3,
.ds-title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.15;
  color: var(--ink);
}

.ds-kicker,
.ds-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.ds-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: inherit;
  text-decoration: none;
}

.ds-logo-word {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.ds-logo-mark,
.ds-logo-dot {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: block;
  border-radius: 26%;
  object-fit: contain;
  background: none;
}

.ds-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-4);
}

.ds-nav a,
.ds-nav a:link,
.ds-nav a:visited {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.92rem;
  border-bottom: 1px solid transparent;
}

.ds-nav a:hover,
.ds-nav a:focus-visible,
.ds-nav a[aria-current="page"] {
  color: var(--indigo);
  border-bottom-color: var(--indigo);
}

.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  min-width: 44px;
  padding: 10px 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-bright);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition:
    background var(--motion) ease,
    border-color var(--motion) ease,
    color var(--motion) ease,
    box-shadow var(--motion) ease,
    transform var(--motion) ease;
}

.ds-btn:hover {
  background: var(--btn-hover);
  box-shadow: var(--shadow-hover);
}

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

.ds-btn-primary {
  background: var(--cta);
  border-color: var(--cta);
  color: var(--cta-ink);
  box-shadow: var(--shadow-1);
}

.ds-btn-primary:hover {
  background: var(--cta-hover);
  border-color: var(--cta-hover);
  color: var(--cta-ink);
}

.ds-btn-ghost,
.ds-btn-secondary {
  background: var(--paper-shade);
  border-color: var(--line-strong);
  color: var(--ink-strong);
  box-shadow: var(--shadow-1);
}

.ds-btn-ghost:hover,
.ds-btn-secondary:hover {
  background: color-mix(in srgb, var(--cta) 18%, var(--paper-shade));
  border-color: var(--cta);
  color: var(--ink-strong);
  box-shadow: var(--shadow-1);
}

.ds-btn-danger {
  background: var(--vermillon);
  border-color: var(--vermillon);
  color: var(--ivory);
}

.ds-btn-success {
  background: var(--matcha);
  border-color: var(--matcha);
  color: var(--ivory);
}

.ds-root :where(a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.ds-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ds-field input,
.ds-field select,
.ds-field textarea {
  font-family: var(--font-sans);
  font-size: 1rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  background: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 44px;
  padding: 8px 12px;
  box-shadow: var(--shadow-1);
}

.ds-card,
.ds-cartouche {
  position: relative;
  background: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  transition: box-shadow var(--motion) ease, transform var(--motion) ease;
}

.ds-card:hover,
.ds-cartouche:hover { box-shadow: var(--shadow-hover); }

.ds-panel {
  position: relative;
  margin: 16px 0 24px;
  padding: 16px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper-bright);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.ds-card-accent { border-top: 2px solid var(--indigo); }

.ds-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper-bright);
  color: var(--ink);
  font-size: 0.82rem;
}

.ds-chip-indigo {
  background: var(--indigo-soft);
  border-color: color-mix(in srgb, var(--indigo) 35%, var(--line));
  color: var(--indigo);
}

.ds-chip-matcha {
  background: var(--matcha-soft);
  border-color: color-mix(in srgb, var(--matcha) 35%, var(--line));
  color: var(--matcha);
}

.ds-chip-vermillon {
  background: var(--vermillon-soft);
  border-color: color-mix(in srgb, var(--vermillon) 35%, var(--line));
  color: var(--vermillon);
}

.ds-badge,
.ds-soon {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ds-soon {
  color: var(--muted);
  border-style: dashed;
}

.ds-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ds-motif {
  pointer-events: none;
  opacity: var(--motif-opacity);
}

.ds-host {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 72px;
}

.ds-host.is-soon,
.ds-host[aria-disabled="true"] {
  opacity: 0.72;
}

.ds-host.is-soon .ds-host-body,
.ds-host[aria-disabled="true"] .ds-host-body {
  filter: grayscale(0.15);
}

.ds-streak {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper-bright);
  box-shadow: var(--shadow-1);
  color: inherit;
  text-decoration: none;
}

.ds-streak strong {
  font-family: var(--font-mono);
  font-weight: 600;
}

.ds-xp {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ds-xp-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--gris);
  overflow: hidden;
}

.ds-xp-track > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--indigo);
}

.ds-badge-hex {
  width: 72px;
  height: 80px;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: var(--paper-wash);
  border: 0;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
  padding: 10px;
}

.ds-badge-hex.is-locked {
  box-shadow: inset 0 0 0 1px var(--line);
}

.ds-offer {
  display: grid;
  gap: var(--space-4);
}

.ds-offer .ds-price {
  font-family: var(--font-mono);
  font-size: 2rem;
  letter-spacing: -0.03em;
  margin: 0;
}

.ds-share {
  display: grid;
  gap: var(--space-3);
  min-height: 140px;
}

.ds-share-grid {
  width: 56px;
  height: 56px;
  border: 1px solid var(--line);
  background:
    linear-gradient(var(--ink) 1px, transparent 1px) 0 0 / 33.33% 33.33%,
    linear-gradient(90deg, var(--ink) 1px, transparent 1px) 0 0 / 33.33% 33.33%,
    var(--paper-wash);
  opacity: 0.35;
}

.ds-mode {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--paper);
  gap: 2px;
}

.ds-mode button {
  min-height: 36px;
  padding: 6px 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.ds-mode button[aria-pressed="true"] {
  background: var(--indigo);
  color: var(--ivory);
}

.ds-pulse-ok {
  animation: ds-pulse-ok var(--motion-slow) ease;
}

.ds-shake-bad {
  animation: ds-shake-bad 240ms ease;
}

@keyframes ds-pulse-ok {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--matcha) 0%, transparent); }
  40% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--matcha) 28%, transparent); }
  100% { box-shadow: var(--shadow-1); }
}

@keyframes ds-shake-bad {
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

@media (prefers-reduced-motion: reduce) {
  .ds-pulse-ok,
  .ds-shake-bad { animation: none; }
}

/* Mobile-first: main surfaces use ~95% width and stay centered.
   Keep a narrower measure only when type, a board, or a modal needs it. */
@media (max-width: 760px) {
  .ds-root .ds-card,
  .ds-root .ds-cartouche,
  .ds-root .ds-panel,
  .ds-root .ds-form,
  .ds-root .ds-list,
  .ds-root .ds-offer,
  .ds-root .ds-share {
    width: var(--mobile-content-width, 95%);
    max-width: none;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
  }

  .ds-root .ds-field input,
  .ds-root .ds-field select,
  .ds-root .ds-field textarea {
    width: 100%;
    max-width: none;
  }

  .ds-root .ds-actions,
  .ds-root .ds-hero-actions,
  .ds-root .ds-keypad {
    width: var(--mobile-content-width, 95%);
    max-width: none;
    margin-left: auto;
    margin-right: auto;
  }

  .ds-root .ds-actions:has(> :nth-child(-n+3):last-child),
  .ds-root .ds-hero-actions:has(> :nth-child(-n+3):last-child),
  .ds-root .ds-keypad:has(> :nth-child(-n+3):last-child) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: var(--space-3);
  }

  .ds-root .ds-actions:has(> :nth-child(-n+3):last-child) > *,
  .ds-root .ds-hero-actions:has(> :nth-child(-n+3):last-child) > *,
  .ds-root .ds-keypad:has(> :nth-child(-n+3):last-child) > * {
    width: 100%;
    min-width: 0;
    min-height: 52px;
  }
}
