/* Low Gravitas — shared layout CSS
   Color variables come from low-gravitas-zen.css (linked separately). */

/* @property must live outside @layer (spec limitation) */
@property --hue {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: true;
}

@property --hue2 {
  syntax: '<angle>';
  initial-value: 120deg;
  inherits: true;
}

@layer tokens, base, components, demos;

@layer tokens {
  :root {
    /* ── Typography ── */
    --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-mono:   "SF Mono", "Fira Code", "JetBrains Mono", "Menlo", monospace;
    --font-symbol: "LowGravitasSymbols", monospace;

    --text-xs:     0.75rem;
    --text-sm:     0.875rem;
    --text-base:   1rem;
    --text-lg:     1.1rem;
    --text-xl:     1.25rem;
    --text-2xl:    2rem;
    --text-3xl:    2.4rem;

    --leading-tight:   1.3;
    --leading-snug:    1.5;
    --leading-normal:  1.6;
    --leading-relaxed: 1.75;

    /* ── Radii (raw scale) ── */
    --radius-sm:  4px;
    --radius-md:  6px;
    --radius-lg:  10px;
    --radius-xl:  12px;

    /* ── Shadows / Depth (neumorphic dual-directional) ── */
    --shadow-raised:    3px 3px 8px rgba(0,0,0,0.3), -3px -3px 8px rgba(60,48,30,0.08);
    --shadow-raised-sm: 2px 2px 4px rgba(0,0,0,0.25), -2px -2px 4px rgba(60,48,30,0.06);
    --shadow-pressed:    inset 2px 2px 5px rgba(0,0,0,0.3), inset -2px -2px 5px rgba(60,48,30,0.06);
    --shadow-pressed-sm: inset 1px 1px 3px rgba(0,0,0,0.25), inset -1px -1px 3px rgba(60,48,30,0.05);
    --shadow-drop:    0 6px 24px rgba(0, 0, 0, 0.4);

    /* ── Surface gradients ── */
    --surface-light: #443828;
    --surface-dark:  #1e1409;
    --grad-surface: linear-gradient(145deg, var(--surface-light), var(--surface-dark));
    --grad-pressed: linear-gradient(145deg, var(--surface-dark), var(--surface-light));

    /* ── Background vignette ── */
    --bg-center: var(--surface);
    --bg-edge: #050300;

    /* ── Sticky glass overlay ── */
    --sticky-bg: rgba(20,15,4,0.75);

    /* ── Motion ── */
    --duration-fast:   0.15s;
    --duration-normal: 0.3s;

    /* ── Layout ── */
    --content-narrow: 720px;
    --content-wide:   960px;

    /* ── Borders ── */
    --border-faint:  var(--border-faint);
    --border-subtle: rgba(168,152,128,0.1);
    --border-light:  rgba(168,152,128,0.15);
    --border-medium: var(--border-medium);

    /* ── Semantic aliases (experimentation surface) ── */
    --surface-radius:     var(--radius-lg);
    --surface-shadow:     var(--shadow-raised-sm);
    --surface-hover-glow: none;
    --btn-radius:         var(--radius-lg);
    --code-radius:        var(--radius-lg);
    --accent-hover:       var(--lgz-bright-blue);
  }

  [data-theme="light"] {
    --shadow-raised:    3px 3px 8px rgba(166,150,128,0.2), -3px -3px 8px rgba(255,255,255,0.5);
    --shadow-raised-sm: 2px 2px 4px rgba(166,150,128,0.18), -2px -2px 4px rgba(255,255,255,0.4);
    --shadow-pressed:    inset 2px 2px 5px rgba(166,150,128,0.18), inset -2px -2px 5px rgba(255,255,255,0.4);
    --shadow-pressed-sm: inset 1px 1px 3px rgba(166,150,128,0.15), inset -1px -1px 3px rgba(255,255,255,0.35);
    --shadow-drop:    0 6px 24px rgba(0, 0, 0, 0.2);
    --surface-light: #e4dace;
    --surface-dark:  #d0c5b6;
    --bg-edge: #c8bca8;
    --sticky-bg: rgba(200,188,168,0.8);
  }
}

@layer base {

/* ── Reset ── */

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

/* ── Body ── */

body {
  font-family: var(--font-sans);
  background: radial-gradient(ellipse at 50% 40%, var(--bg-center, var(--bg)) 0%, var(--bg-edge) 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* ── Links ── */

a { color: var(--link); }
a:hover { color: var(--accent); }

/* ── Symbol font ── */

@font-face {
  font-family: 'LowGravitasSymbols';
  src: url('/vendor/LowGravitasSymbols.ttf') format('truetype');
  font-display: swap;
}
.lg { font-family: var(--font-symbol); }

} /* end @layer base — iridescent/ripple systems are in @layer components below */

@layer components {

/* ══════════════════════════════════════════════════════
   Iridescent system — dual-layer, auto-rotating, edge-weighted
   ══════════════════════════════════════════════════════ */

:root {
  animation: iri-rotate 11s linear infinite;
}

@keyframes iri-rotate {
  from { --hue: 0deg; --hue2: 120deg; }
  to   { --hue: 360deg; --hue2: -240deg; }
}

.iridescent {
  position: relative;
}

/* Layer 1 (::before) — rotates with --hue */
.iridescent::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(
    from var(--hue, 0deg),
    rgba(255,255,134,0.21),
    rgba(124,175,194,0.21),
    rgba(186,139,175,0.16),
    rgba(135,214,135,0.13),
    rgba(255,255,134,0.21)
  );
  mask: radial-gradient(farthest-side at 50% 50%, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.1) 38%, rgba(255,255,255,0.75) 100%);
  -webkit-mask: radial-gradient(farthest-side at 50% 50%, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.1) 38%, rgba(255,255,255,0.75) 100%);
  pointer-events: none;
  animation: iri-layer1-fade 4s ease-in-out infinite alternate;
}

@keyframes iri-layer1-fade {
  0%   { opacity: 0.35; }
  100% { opacity: 0; }
}

.iridescent:hover::before {
  animation: iri-layer1-fade-hover 4s ease-in-out infinite alternate;
}

@keyframes iri-layer1-fade-hover {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Layer 2 (.iri-layer2) — rotates with --hue2, fades opposite of layer 1 */
.iri-layer2 {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(
    from var(--hue2, 120deg),
    rgba(186,139,175,0.21),
    rgba(255,255,134,0.18),
    rgba(135,214,135,0.16),
    rgba(124,175,194,0.21),
    rgba(186,139,175,0.21)
  );
  mask: radial-gradient(farthest-side at 50% 50%, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.1) 38%, rgba(255,255,255,0.75) 100%);
  -webkit-mask: radial-gradient(farthest-side at 50% 50%, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.1) 38%, rgba(255,255,255,0.75) 100%);
  pointer-events: none;
  animation: iri-layer2-fade 4s ease-in-out infinite alternate;
}

@keyframes iri-layer2-fade {
  0%   { opacity: 0; }
  100% { opacity: 0.35; }
}

.iridescent:hover .iri-layer2 {
  animation: iri-layer2-fade-hover 4s ease-in-out infinite alternate;
}

@keyframes iri-layer2-fade-hover {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* Dark mode damping for non-primary elements */
[data-theme="dark"] .iridescent:not(.btn-primary)::before {
  background: conic-gradient(
    from var(--hue, 0deg),
    rgba(255,255,134,0.14),
    rgba(124,175,194,0.14),
    rgba(186,139,175,0.10),
    rgba(135,214,135,0.08),
    rgba(255,255,134,0.14)
  );
  opacity: 0.25;
}

[data-theme="dark"] .iridescent:not(.btn-primary):hover::before {
  opacity: 0.75;
}

[data-theme="dark"] .iridescent:not(.btn-primary) .iri-layer2 {
  background: conic-gradient(
    from var(--hue2, 120deg),
    rgba(186,139,175,0.14),
    rgba(255,255,134,0.12),
    rgba(135,214,135,0.10),
    rgba(124,175,194,0.14),
    rgba(186,139,175,0.14)
  );
}

.iridescent:disabled::before,
.iridescent[aria-disabled="true"]::before {
  display: none;
}

/* ══════════════════════════════════════════════════════
   Ripple contour system
   ══════════════════════════════════════════════════════ */

/* Static contour — only for elements WITHOUT ripple */
.clay-ring:not(.clay-ripple)::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow:
    1px 1px 3px rgba(0,0,0,0.5),
    -1px -1px 3px rgba(100,82,52,0.32);
  opacity: 0;
  pointer-events: none;
  transition: inset 0.35s ease, opacity 0.3s ease;
}

.clay-ring:not(.clay-ripple):hover::after {
  inset: -5px;
  opacity: 1;
}

[data-theme="light"] .clay-ring:not(.clay-ripple)::after {
  box-shadow:
    1px 1px 3px rgba(166,150,128,0.22),
    -1px -1px 3px rgba(255,255,255,0.5);
}

/* Ripple rings — the ripples ARE the contour */
.clay-ripple {
  overflow: visible;
}

.clay-ripple .ripple-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    1px 1px 1px rgba(0,0,0,0.85),
    -1px -1px 1px rgba(160,135,90,0.5);
  opacity: 0;
  pointer-events: none;
}

[data-theme="light"] .clay-ripple .ripple-ring {
  box-shadow:
    1px 1px 1px rgba(120,105,85,0.4),
    -1px -1px 1px rgba(255,255,255,0.85);
}

.clay-ripple:hover .ripple-ring,
.clay-ripple:focus-within .ripple-ring {
  animation: clay-ripple-out 1.9s ease-out infinite;
}

/* Use adjacent sibling selector, NOT :nth-child (breaks with other children) */
.clay-ripple:hover .ripple-ring + .ripple-ring,
.clay-ripple:focus-within .ripple-ring + .ripple-ring {
  animation-delay: 0.95s;
}

/* Primary buttons need stronger ripples */
.btn-primary.clay-ripple .ripple-ring {
  box-shadow:
    2px 2px 2px rgba(0,0,0,0.9),
    -2px -2px 2px rgba(160,135,90,0.6);
}

[data-theme="light"] .btn-primary.clay-ripple .ripple-ring {
  box-shadow:
    2px 2px 2px rgba(40,20,60,0.5),
    -2px -2px 2px rgba(255,255,255,0.9);
}

@keyframes clay-ripple-out {
  0%   { inset: 0;     opacity: 0.8; }
  20%  {               opacity: 0.45; }
  55%  {               opacity: 0.12; }
  100% { inset: -10px; opacity: 0; }
}

} /* end @layer components */

@layer base {

/* ── Nav ── */

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-faint);
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--sticky-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

nav .nav-left {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
}

[data-theme="light"] .brand-logo {
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.7));
}

nav .nav-right { display: flex; gap: 6px; align-items: center; }

nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: var(--text-sm);
  padding: 10px 14px;
  border-radius: var(--btn-radius);
  position: relative;
  transition: color var(--duration-fast);
}
nav a:hover { color: var(--text); }

nav a.nav-left { font-size: 1rem; color: var(--text); padding: 0; }
nav a.nav-left:hover { color: var(--accent); }

#theme-toggle {
  background: var(--grad-surface);
  box-shadow: var(--shadow-raised-sm);
  border: none;
  border-radius: var(--btn-radius);
  cursor: pointer;
  color: var(--text);
  transition: transform var(--duration-fast);
  font-family: var(--font-symbol);
  font-size: 16px;
  line-height: 1;
  padding: 0;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
#theme-toggle:hover { transform: translateY(-1px); }
#theme-toggle:active {
  box-shadow: var(--shadow-pressed-sm);
  background: var(--grad-pressed);
  transform: scale(0.97);
}
#theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--btn-radius);
  border: 1px solid var(--border-medium);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--grad-surface);
  box-shadow: var(--shadow-raised-sm);
  color: var(--text);
  text-decoration: none;
  position: relative;
  transition: transform var(--duration-fast);
}

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

.btn:active {
  box-shadow: var(--shadow-pressed-sm);
  background: var(--grad-pressed);
  transform: scale(0.97);
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

[data-theme="light"] .btn {
  border-color: rgba(90,78,62,0.2);
}

/* Primary button — stacked iridescent gradient */
.btn-primary {
  background:
    radial-gradient(farthest-side at 50% 50%, rgba(255,255,134,1) 0%, rgba(255,255,134,0.97) 38%, rgba(255,255,134,0.7) 100%),
    conic-gradient(from var(--hue, 0deg), #e8c840, #60b8d0, #c070b0, #60c880, #e8c840);
  color: #1a1208;
  border: none;
  transition: background 0.3s ease, transform 0.2s ease;
}

.btn-primary:hover {
  color: #1a1208;
  background:
    radial-gradient(farthest-side at 50% 50%, rgba(255,255,134,0.98) 0%, rgba(255,255,134,0.93) 38%, rgba(255,255,134,0.5) 100%),
    conic-gradient(from var(--hue, 0deg), #e8c840, #60b8d0, #c070b0, #60c880, #e8c840);
}

.btn-primary:active {
  background:
    radial-gradient(farthest-side at 50% 50%, rgba(232,232,112,0.5) 0%, rgba(232,232,112,1) 100%),
    conic-gradient(from var(--hue, 0deg), #e8c840, #60b8d0, #c070b0, #60c880, #e8c840);
}

[data-theme="light"] .btn-primary {
  background:
    radial-gradient(farthest-side at 50% 50%, rgba(92,45,145,0.98) 0%, rgba(92,45,145,0.93) 38%, rgba(92,45,145,0.35) 100%),
    conic-gradient(from var(--hue, 0deg), #7040a0, #4090b0, #a05090, #409880, #7040a0);
  color: #fff;
}

[data-theme="light"] .btn-primary:hover {
  color: #fff;
  background:
    radial-gradient(farthest-side at 50% 50%, rgba(92,45,145,0.93) 0%, rgba(92,45,145,0.8) 38%, rgba(92,45,145,0.15) 100%),
    conic-gradient(from var(--hue, 0deg), #7040a0, #4090b0, #a05090, #409880, #7040a0);
}

/* Ghost button — borderless, faint transparent background */
.btn-ghost {
  background: rgba(60,48,36,0.2);
  box-shadow: none;
  border: none;
  color: var(--text-dim);
}

.btn-ghost:hover {
  background: rgba(60,48,36,0.4);
  box-shadow: none;
  color: var(--text);
}

.btn-ghost:active {
  background: var(--grad-pressed);
  box-shadow: var(--shadow-pressed-sm);
  transform: scale(0.97);
}

[data-theme="light"] .btn-ghost {
  background: rgba(219,208,194,0.2);
  box-shadow: none;
  border: none;
}

[data-theme="light"] .btn-ghost:hover {
  background: rgba(219,208,194,0.4);
  box-shadow: none;
}

/* Disabled button */
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.35;
  filter: grayscale(0.3);
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Footer ── */

footer {
  border-top: 1px solid var(--border-faint);
  padding: 16px 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: var(--text-xs);
}
footer a { color: var(--text-dim); text-decoration: none; }
footer a:hover { color: var(--link); }

/* ── Accessibility ── */

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

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: var(--text-on-accent);
  padding: 8px 16px;
  z-index: 100;
  text-decoration: none;
  font-size: var(--text-sm);
  transition: top var(--duration-fast);
}
.skip-link:focus { top: 0; }

/* ── Animations ── */

.fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.fade-in.visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  :root { animation: none; }
  .iridescent::before, .iri-layer2 { animation: none; opacity: 0.2; }
  .clay-ripple:hover .ripple-ring,
  .clay-ripple:focus-within .ripple-ring { animation: none; }
  .clay-ring:not(.clay-ripple)::after { transition: none; }
  .fade-in { opacity: 1; transform: none; transition: none; }
  .btn { transition: none; }
  .skip-link { transition: none; }
  nav a { transition: none; }
  #theme-toggle { transition: none; }
}

/* ── Selection ── */

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

/* ── Responsive nav ── */

@media (max-width: 640px) {
  nav {
    flex-wrap: wrap;
    gap: 8px;
  }
  nav a {
    padding: 8px 10px;
  }
}

} /* end @layer base */
