/* Copyright 2026 Phillip Cloud */
/* Licensed under the Apache License, Version 2.0 */

/* Shared palette and theme-toggle styles -- imported by website.css, docs.css, and blog.css */

:root {
  --cream: #faf6f1;
  --linen: #f0ebe4;
  --charcoal: #2d2a26;
  --charcoal-soft: #4a4640;
  --terracotta: #c05e3c;
  --terracotta-dark: #a04e30;
  --terracotta-darker: #8a4128;
  --sage: #6b8f71;
  --sage-strong: #3e5d44;
  --warm-gray: #736961;
  --rule: #d9d2c9;
  --code-bg: #2d2a26;
  --code-text: #e8e2da;
  --shadow-color: rgba(45, 42, 38, 0.12);
  --overlay-bg: rgba(45, 42, 38, 0.5);
  --toggle-bg: var(--linen);
  --toggle-bg-hover: #e8e2da;
  --toggle-hover-speed: 0.15s;
  --cloud: #b8b0a5;
  --rect-fill: rgba(192, 94, 60, 0.15);
}

[data-theme="dark"] {
  --cream: #242019;
  --linen: #1c1916;
  --charcoal: #e8ddd0;
  --charcoal-soft: #a89e91;
  --terracotta: #d4764e;
  --terracotta-dark: #e0835a;
  --terracotta-darker: #ed9670;
  --sage: #7fa882;
  --sage-strong: #7fa882;
  --warm-gray: #9a907f;
  --rule: #3d3730;
  --code-bg: #1c1916;
  --code-text: #e8ddd0;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --overlay-bg: rgba(0, 0, 0, 0.5);
  --toggle-bg: #342f29;
  --toggle-bg-hover: var(--rule);
  --rect-fill: rgba(212, 118, 78, 0.10);
}

/* High-contrast overrides for users who request stronger contrast at
   the OS level. Push tertiary text and links from AA (~5:1) to AAA
   (>=7:1) without touching the brand identity colors used at heading
   sizes. */
@media (prefers-contrast: more) {
  :root {
    --warm-gray: #544c45;       /* 7.9:1 on cream */
    --terracotta-dark: #7a3a23; /* 8.0:1 on cream */
  }

  [data-theme="dark"] {
    --warm-gray: #beb09e;                /* 7.6:1 on dark cream */
    --terracotta-dark: var(--terracotta-darker); /* 7.0:1 */
  }
}

/* --- Skip link (shared across all pages) --- */

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.5rem 0.75rem;
  background: var(--charcoal);
  color: var(--cream);
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.85rem;
  text-decoration: none;
  border-radius: 0 0 6px 0;
  transform: translateY(-100%);
  transition: transform 0.15s ease-out;
  z-index: 500;
}

.skip-link:focus {
  transform: translateY(0);
  color: var(--cream);
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

/* --- Theme toggle (shared across all pages) --- */

.theme-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 400;
  background: var(--toggle-bg);
  border: none;
  border-radius: 6px;
  padding: 3px;
  cursor: pointer;
  line-height: 0;
  transition: background-color var(--toggle-hover-speed);
}

.theme-toggle:hover {
  background: var(--toggle-bg-hover);
}

.moon-y circle:last-child {
  transition: fill var(--toggle-hover-speed);
}

.theme-toggle:hover .moon-y circle:last-child {
  fill: var(--toggle-bg-hover);
}

.theme-house {
  display: block;
}

.github-link {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.github-link svg {
  display: block;
}

/* --- Sun arc: rests upper-right in light, hides behind house in dark --- */

.sun-x {
  transition: transform 0.6s ease-out;
}

.sun-y {
  transition: transform 0.6s ease-in, opacity 0.4s ease-in;
}

[data-theme="dark"] .sun-x {
  transform: translateX(-10px);
}

[data-theme="dark"] .sun-y {
  transform: translateY(22px);
  opacity: 0;
}

/* --- Moon arc: rests upper-left in dark, hides behind house in light --- */

.moon-x {
  transform: translateX(10px);
  transition: transform 0.6s ease-out;
}

.moon-y {
  transform: translateY(22px);
  opacity: 0;
  transition: transform 0.6s ease-in, opacity 0.4s ease-in;
}

[data-theme="dark"] .moon-x {
  transform: translateX(0);
  transition: transform 0.6s ease-out 0.15s;
}

[data-theme="dark"] .moon-y {
  transform: translateY(0);
  opacity: 1;
  transition: transform 0.6s ease-out 0.15s, opacity 0.4s ease-out 0.15s;
}

/* --- Stars --- */

@keyframes twinkle {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

.sky-stars { opacity: 0; transition: opacity 0.5s; }
[data-theme="dark"] .sky-stars { opacity: 1; }

.star { opacity: 0.2; }
.star-1 { animation: twinkle 2s ease-in-out infinite; }
.star-2 { animation: twinkle 2s ease-in-out 0.5s infinite; }
.star-3 { animation: twinkle 2s ease-in-out 1s infinite; }
.star-4 { animation: twinkle 2s ease-in-out 1.5s infinite; }
.star-5 { animation: twinkle 2s ease-in-out 0.8s infinite; }

/* --- Cloud (light mode only) --- */

@keyframes cloud-drift {
  from { transform: translateX(-16px); }
  to { transform: translateX(52px); }
}

@keyframes cloud-bob {
  0%, 100% { transform: translateY(-5px); }
  50% { transform: translateY(5px); }
}

.sky-clouds { transition: opacity 0.5s; }
[data-theme="dark"] .sky-clouds { opacity: 0; }

.cloud-drift { animation: cloud-drift 28s linear infinite; }
.cloud-bob { animation: cloud-bob 131s linear infinite; }

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  .sun-x, .sun-y, .moon-x, .moon-y { transition: none; }
  .sky-stars, .sky-clouds { transition: none; }
  .star { animation: none; }
  .cloud-drift { animation: none; transform: translateX(18px); }
  .cloud-bob { animation: none; }
  [data-theme="dark"] .sun-y { opacity: 0; }
  .moon-y { opacity: 0; }
  [data-theme="dark"] .moon-y { opacity: 1; }
}

/* --- Pause animations while tab is hidden (idle-pause.js syncs this) --- */

.animations-paused .star,
.animations-paused .cloud-drift,
.animations-paused .cloud-bob,
.animations-paused .cursor::after {
  animation-play-state: paused;
}

/* --- Touch-target sizing (shared chrome) --- */

@media (pointer: coarse), (hover: none) {
  .theme-toggle {
    padding: 10px;
  }
}

/* --- Markdown table alignment classes (used by render-table.html) --- */

.ta-left { text-align: left; }
.ta-center { text-align: center; }
.ta-right { text-align: right; }

/* --- Print: hide interactive chrome shared across all pages --- */

@media print {
  .skip-link,
  .theme-toggle {
    display: none !important;
  }

  /* Force readable colors on paper regardless of theme. */
  :root,
  [data-theme="dark"] {
    --cream: #ffffff;
    --linen: #f5f5f5;
    --charcoal: #1a1a1a;
    --charcoal-soft: #333333;
    --warm-gray: #555555;
    --rule: #cccccc;
    --terracotta: #8a4128;
    --terracotta-dark: #6a3220;
    --terracotta-darker: #4a2316;
    --shadow-color: transparent;
  }

  /* Expand link URLs after the link text for paper readers. */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
    word-break: break-all;
  }

  /* But not for in-page anchors, footnotes, or links whose text already
     reads as a URL (the link text is already the URL). */
  a[href^="#"]::after,
  a[href^="javascript:"]::after,
  a.heading-anchor::after {
    content: "";
  }
}
