/* ============================================
   Tim McGregor — Shared Stylesheet
   See DESIGN-SYSTEM.md for full reference
   ============================================ */

/* --- Colour tokens --- */
:root {
  --bg: #FFFFFF;
  --text: #1A1A1A;
  --text-secondary: #777;
  --text-muted: #888;
  --accent-hover: #2962FF;
  --border: #CCC;
  --border-light: #BBB;
  --toggle-border: #CCC;
  --toggle-icon: #777;
}

[data-theme="dark"] {
  --bg: #0A0A0A;
  --text: #E0E0E0;
  --text-secondary: #999;
  --text-muted: #666;
  --accent-hover: #5C8AFF;
  --border: #444;
  --border-light: #555;
  --toggle-border: #555;
  --toggle-icon: #999;
}

/* --- Selection --- */
::selection {
  background: rgba(41, 98, 255, 0.15);
}

[data-theme="dark"] ::selection {
  background: rgba(92, 138, 255, 0.25);
}

/* --- Reset --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 17px;
}

body {
  font-family: 'Geist', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background-color 0.4s ease, color 0.4s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Layout --- */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

/* --- Toggle buttons (shared) --- */
.toggle-btn {
  position: fixed;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--toggle-border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.3s ease;
  z-index: 100;
}

.toggle-btn:hover {
  border-color: var(--text);
}

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

/* Theme toggle */
.theme-toggle {
  top: 4.35rem;
  right: 1.25rem;
  overflow: hidden;
}

.theme-toggle .icon-wrap {
  position: relative;
  width: 16px;
  height: 16px;
  overflow: hidden;
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  stroke: var(--toggle-icon);
  position: absolute;
  top: 0;
  left: 0;
  transition: transform 0.35s ease, opacity 0.35s ease, stroke 0.3s ease, fill 0.3s ease;
}

.theme-toggle .icon-moon {
  fill: var(--toggle-icon);
}

.theme-toggle:hover svg {
  stroke: var(--text);
}

.theme-toggle:hover .icon-moon {
  fill: var(--text);
}

/* Light mode: sun visible, moon below */
.theme-toggle .icon-sun { transform: translateY(0) rotate(0deg); opacity: 1; }
.theme-toggle .icon-moon { transform: translateY(16px) rotate(-45deg); opacity: 0; }

/* Dark mode: sun above with rotation, moon slides in */
[data-theme="dark"] .theme-toggle .icon-sun { transform: translateY(-16px) rotate(45deg); opacity: 0; }
[data-theme="dark"] .theme-toggle .icon-moon { transform: translateY(0) rotate(0deg); opacity: 1; }

/* Language toggle */
.lang-toggle {
  top: 7.1rem;
  right: 1.25rem;
  font-family: 'Geist', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--toggle-icon);
  letter-spacing: 0.02em;
  transition: border-color 0.3s ease, color 0.3s ease;
  overflow: hidden;
}

.lang-toggle .label-wrap {
  position: relative;
  width: 16px;
  height: 12px;
  overflow: hidden;
}

.lang-toggle .label-ja,
.lang-toggle .label-en {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

/* Default (EN active): show JA label, EN label below */
.lang-toggle .label-ja { transform: translateY(0); opacity: 1; }
.lang-toggle .label-en { transform: translateY(12px); opacity: 0; }

/* JA active: JA label slides up, EN slides in */
[data-lang="ja"] .lang-toggle .label-ja { transform: translateY(-12px); opacity: 0; }
[data-lang="ja"] .lang-toggle .label-en { transform: translateY(0); opacity: 1; }

.lang-toggle:hover {
  color: var(--text);
}

/* --- Crossfade transition --- */
.translatable {
  transition: opacity 0.35s ease;
}

.translatable.fading {
  opacity: 0;
}

/* --- Japanese text styling --- */
[data-lang="ja"] .bio,
[data-lang="ja"] .section-item,
[data-lang="ja"] .body-text,
[data-lang="ja"] footer {
  font-family: 'Noto Sans JP', sans-serif;
  letter-spacing: 0.04em;
  word-break: auto-phrase;
}

[data-lang="ja"] .bio p,
[data-lang="ja"] .body-text p {
  font-size: 0.9rem;
  line-height: 1.9;
}

[data-lang="ja"] .bio strong,
[data-lang="ja"] .body-text strong {
  font-weight: 500;
}

[data-lang="ja"] .section-item {
  font-size: 0.85rem;
  line-height: 1.8;
}

/* --- Header --- */
header {
  margin-bottom: 2.5rem;
}

h1 {
  font-family: 'Space Grotesk', 'Geist', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-wrap: balance;
}

h1 .subtitle {
  color: var(--text-muted);
}

.header-links {
  display: flex;
  gap: 1rem;
  margin-top: 0.6rem;
  font-size: 0.8rem;
}

.header-links a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px dashed var(--border-light);
  padding-bottom: 1px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.header-links a:hover {
  color: var(--accent-hover);
  border-color: var(--accent-hover);
  border-bottom-style: solid;
}

/* --- Bio / Body text --- */
.bio,
.body-text {
  margin-bottom: 3rem;
}

.bio p,
.body-text p {
  margin-bottom: 1.1rem;
  font-size: 0.95rem;
  font-weight: 400;
}

.bio p:last-child,
.body-text p:last-child {
  margin-bottom: 0;
}

.bio strong,
.body-text strong {
  font-weight: 600;
}

/* --- Sections --- */
section {
  margin-bottom: 2.5rem;
}

section:last-of-type {
  margin-bottom: 0;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.section-label svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  flex-shrink: 0;
  transform: translateY(-1px);
}

/* --- Section items --- */
.section-item {
  font-size: 0.9rem;
  line-height: 1.6;
}

.section-item + .section-item {
  margin-top: 0.2rem;
}

.section-item a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 1px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.section-item a:hover {
  color: var(--accent-hover);
  border-color: var(--accent-hover);
  border-bottom-style: solid;
}

/* --- Back link (sub-pages) --- */
.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px dashed var(--border-light);
  padding-bottom: 1px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.back-link:hover {
  color: var(--accent-hover);
  border-color: var(--accent-hover);
  border-bottom-style: solid;
}

/* --- Footer --- */
footer {
  margin-top: 4rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* --- Footer globe --- */
.globe-icon {
  width: 14px;
  height: 14px;
  stroke: var(--text-muted);
  vertical-align: -2px;
  margin-right: 1px;
}


/* --- Colour shuffle link --- */
.colour-shuffle {
  margin-left: 1.5em;
  cursor: pointer;
  letter-spacing: 0.01em;
}

/* --- Entrance animation --- */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  .animate-entrance .container > * {
    animation: fadeSlideIn 0.4s ease-out both;
  }
  .animate-entrance .container > *:nth-child(1) { animation-delay: 0s; }
  .animate-entrance .container > *:nth-child(2) { animation-delay: 0.06s; }
  .animate-entrance .container > *:nth-child(3) { animation-delay: 0.12s; }
  .animate-entrance .container > *:nth-child(4) { animation-delay: 0.18s; }
  .animate-entrance .container > *:nth-child(5) { animation-delay: 0.24s; }
  .animate-entrance .container > *:nth-child(6) { animation-delay: 0.30s; }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  html { font-size: 16px; }
  .container { padding: 3rem 1.25rem 4rem; }
  .theme-toggle { top: 3.35rem; right: 1rem; }
  .lang-toggle { top: 6.1rem; right: 1rem; }
}
