/* Named themes: component-level personality for 70s and Office (docs/DESIGN.md "Named themes").
   Palettes live in tokens.css; this file holds what tokens alone cannot express — display type,
   stripes, grain, borders and selection treatment. Everything is scoped to its data-theme, so
   Light and Dark are untouched. Decorative layers are pseudo-elements or backgrounds with
   pointer-events: none and never sit behind running text. */

/* --- 70s ----------------------------------------------------------------- */

/* Wave tile (orange, gold, turquoise): three parallel sine strokes, one 120px period, drawn
   10px past each tile edge so butt caps never leave a notch where tiles meet. The viewBox is
   sized to the full stroke extent at crests and troughs (centre ± 8 amplitude ± 4.5 half-stroke).
   SVG cannot read custom properties, so the stripe colours repeat here; keep them equal to
   --stripe-1..3 in tokens.css. */
:root[data-theme="70s"] {
  --waves: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='52' viewBox='0 0 120 52'%3E%3Cg fill='none' stroke-width='9'%3E%3Cpath d='M-10,18.00C-6.67,16.79 -3.33,15.40 0,14.00C3.33,12.60 6.67,11.21 10,10.00C13.33,8.79 16.67,7.77 20,7.07C23.33,6.37 26.67,6.00 30,6.00C33.33,6.00 36.67,6.37 40,7.07C43.33,7.77 46.67,8.79 50,10.00C53.33,11.21 56.67,12.60 60,14.00C63.33,15.40 66.67,16.79 70,18.00C73.33,19.21 76.67,20.23 80,20.93C83.33,21.63 86.67,22.00 90,22.00C93.33,22.00 96.67,21.63 100,20.93C103.33,20.23 106.67,19.21 110,18.00C113.33,16.79 116.67,15.40 120,14.00C123.33,12.60 126.67,11.21 130,10.00' stroke='%23df531b'/%3E%3Cpath d='M-10,29.00C-6.67,27.79 -3.33,26.40 0,25.00C3.33,23.60 6.67,22.21 10,21.00C13.33,19.79 16.67,18.77 20,18.07C23.33,17.37 26.67,17.00 30,17.00C33.33,17.00 36.67,17.37 40,18.07C43.33,18.77 46.67,19.79 50,21.00C53.33,22.21 56.67,23.60 60,25.00C63.33,26.40 66.67,27.79 70,29.00C73.33,30.21 76.67,31.23 80,31.93C83.33,32.63 86.67,33.00 90,33.00C93.33,33.00 96.67,32.63 100,31.93C103.33,31.23 106.67,30.21 110,29.00C113.33,27.79 116.67,26.40 120,25.00C123.33,23.60 126.67,22.21 130,21.00' stroke='%23e8a52e'/%3E%3Cpath d='M-10,40.00C-6.67,38.79 -3.33,37.40 0,36.00C3.33,34.60 6.67,33.21 10,32.00C13.33,30.79 16.67,29.77 20,29.07C23.33,28.37 26.67,28.00 30,28.00C33.33,28.00 36.67,28.37 40,29.07C43.33,29.77 46.67,30.79 50,32.00C53.33,33.21 56.67,34.60 60,36.00C63.33,37.40 66.67,38.79 70,40.00C73.33,41.21 76.67,42.23 80,42.93C83.33,43.63 86.67,44.00 90,44.00C93.33,44.00 96.67,43.63 100,42.93C103.33,42.23 106.67,41.21 110,40.00C113.33,38.79 116.67,37.40 120,36.00C123.33,34.60 126.67,33.21 130,32.00' stroke='%23169c89'/%3E%3C/g%3E%3C/svg%3E");
  /* Printed-paper grain: faint monochrome noise over flat colour. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .95 0 0 0 0 .8 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

[data-theme="70s"] body,
[data-theme="70s"] .topbar,
[data-theme="70s"] .sidebar,
[data-theme="70s"] .bottomnav,
[data-theme="70s"] .card {
  background-image: var(--grain);
}

[data-theme="70s"] .brand,
[data-theme="70s"] h1,
[data-theme="70s"] .state__title {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
}

[data-theme="70s"] h1 {
  margin-bottom: var(--space-3);
  font-size: 2rem;
  color: var(--ink);
}

[data-theme="70s"] .brand {
  color: var(--ink);
}

[data-theme="70s"] .brand img {
  border-radius: 0;
}

/* Stripes: a vertical band on the rail's edge, a horizontal band under the top bar. */
[data-theme="70s"] .sidebar,
[data-theme="70s"] .topbar {
  border-color: #1a130b;
}

/* The stripe is a background layer of the rail itself, not a pseudo-element, so it stays on the
   edge while a short viewport scrolls the rail. Keep the 18px equal to the padding below. */
[data-theme="70s"] .sidebar {
  padding-right: calc(var(--space-3) + 18px);
  background-image:
    linear-gradient(
      to right,
      transparent calc(100% - 18px),
      var(--stripe-1) calc(100% - 18px) calc(100% - 12px),
      var(--stripe-2) calc(100% - 12px) calc(100% - 6px),
      var(--stripe-3) calc(100% - 6px)
    ),
    var(--grain);
}

[data-theme="70s"] .topbar {
  border-color: #1a130b;
}

[data-theme="70s"] .sidebar::after {
  content: "";
  position: absolute;
  inset-block: 0;
  right: 0;
  width: 18px;
  background: linear-gradient(to right, var(--stripe-1) 33.3%, var(--stripe-2) 33.3% 66.6%, var(--stripe-3) 66.6%);
  pointer-events: none;
}

[data-theme="70s"] .sidebar {
  padding-right: calc(var(--space-3) + 18px);
}

[data-theme="70s"] .topbar {
  padding-bottom: calc(var(--space-2) + 9px);
}

[data-theme="70s"] .topbar::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 9px;
  background: linear-gradient(to bottom, var(--stripe-1) 33.3%, var(--stripe-2) 33.3% 66.6%, var(--stripe-3) 66.6%);
  pointer-events: none;
}

/* The wave motif fills the strip above the page content. */
[data-theme="70s"] .main::before {
  content: "";
  display: block;
  height: 52px;
  margin-bottom: var(--space-5);
  background: var(--waves) repeat-x left center;
  pointer-events: none;
}

/* Disco draws the same three ribbons as an animated tail from the ball (js/disco-lights.js); the
   strip keeps its height so content does not move. */
[data-theme="70s"][data-disco-tail] .main::before {
  background: none;
}

[data-theme="70s"] .bottomnav {
  border-top: 3px solid var(--stripe-2);
}

/* Selection: gold block plus a heavy edge, so it never relies on colour alone. */
[data-theme="70s"] .nav-link[aria-current="page"] {
  box-shadow: inset 5px 0 0 var(--stripe-1);
  font-weight: 700;
}

[data-theme="70s"] .bottomnav .nav-link[aria-current="page"] {
  box-shadow: inset 0 4px 0 var(--stripe-1);
}

[data-theme="70s"] .btn,
[data-theme="70s"] .theme-select,
[data-theme="70s"] .icon-btn {
  border: 2px solid var(--ink);
}

[data-theme="70s"] .icon-btn {
  border-color: transparent;
}

[data-theme="70s"] .icon-btn--text {
  border-color: var(--ink);
}

[data-theme="70s"] .btn {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--text-s);
}

[data-theme="70s"] .btn--secondary,
[data-theme="70s"] .theme-select {
  background: var(--surface-raised);
}

[data-theme="70s"] .btn--primary:hover {
  filter: none;
  background: var(--stripe-1);
  color: #ffffff;
  text-decoration: underline;
}

[data-theme="70s"] .card {
  border: 2px solid var(--ink);
  background-color: var(--surface-raised);
  box-shadow: 6px 6px 0 var(--stripe-3);
}

[data-theme="70s"] .state__icon {
  border: 2px solid var(--ink);
}

[data-theme="70s"] .spinner {
  border-color: var(--line);
  border-top-color: var(--stripe-2);
}

[data-theme="70s"] .offline-bar {
  border-bottom: 3px solid var(--stripe-1);
}

/* --- Office -------------------------------------------------------------- */

[data-theme="office"] h1 {
  font-size: var(--text-l);
  font-weight: 700;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}

[data-theme="office"] .view {
  animation: none;
}

[data-theme="office"] .topbar,
[data-theme="office"] .sidebar,
[data-theme="office"] .bottomnav,
[data-theme="office"] .rail-controls {
  border-color: var(--line);
}

[data-theme="office"] .nav-link {
  border: 1px solid transparent;
}

[data-theme="office"] .nav-link:hover {
  border-color: var(--line);
}

/* Selection: filled navy block with a bold label, never only a colour change. */
[data-theme="office"] .nav-link[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

[data-theme="office"] .nav-link[aria-current="page"] svg {
  color: var(--accent-ink);
}

[data-theme="office"] .btn {
  border-color: var(--ink-muted);
  font-weight: 400;
}

[data-theme="office"] .btn--primary {
  border-color: var(--accent);
}

[data-theme="office"] .btn--secondary,
[data-theme="office"] .theme-select {
  background: var(--surface-raised);
  border-color: var(--ink-muted);
}

[data-theme="office"] .icon-btn--text {
  border: 1px solid var(--ink-muted);
}

[data-theme="office"] .card,
[data-theme="office"] .state__icon {
  border: 1px solid var(--line);
  background: var(--surface-raised);
}

[data-theme="office"] .state__icon {
  border-radius: 0;
}

[data-theme="office"] .offline-bar {
  border-bottom: 1px solid var(--line);
}

/* --- 70s disco mode (opt-in; docs/DESIGN.md "Disco mode") ------------------ */

/* The only animated decoration in the app, shown solely while the user has switched disco mode
   on. A transparent fixed overlay over the whole viewport (explicit exception to "never behind
   running text", docs/DESIGN.md): it takes no pointer events, no focus and no layout, and the
   canvas inside is drawn by js/disco-lights.js (static under reduced motion). */
[data-theme="70s"] .disco-decor {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

[data-theme="70s"] .disco-decor canvas {
  display: block;
  width: 100%;
  height: 100%;
}

[data-theme="70s"] .btn--disco[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink-soft);
}

.btn--disco__state {
  padding-inline: var(--space-1);
  border: 1px solid currentcolor;
  border-radius: var(--radius-s);
  font-size: var(--text-xs);
}

/* Mobile top bar: icon and on/off state only, like the install control. */
@media (max-width: 819.98px) {
  .btn--disco .btn--disco__label {
    display: none;
  }
}

.disco-notice {
  position: fixed;
  z-index: 6;
  inset-inline: var(--space-4);
  bottom: calc(var(--space-7) + var(--space-6) + env(safe-area-inset-bottom));
  max-width: 420px;
  margin-inline: auto;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface-raised);
  color: var(--ink);
  font-size: var(--text-s);
}

.disco-notice:empty {
  display: none;
}

@media (min-width: 820px) {
  .disco-notice {
    inset-inline: auto var(--space-5);
    bottom: var(--space-5);
    margin: 0;
  }
}
