/* ═══════════════════════════════════════════════════
   THE OPEN SHELF LIBRARY — styles.css
   Swiss Precision · Japanese Restraint
   ═══════════════════════════════════════════════════ */

/* ═══ RESET & BASE ═══ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

ul {
  list-style: none;
}

address {
  font-style: normal;
}

/* ═══ CSS VARIABLES — LIGHT THEME ═══ */
:root {
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-light: rgba(37, 99, 235, 0.1);
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8FAFC;
  --bg-tertiary: #F1F5F9;
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-tertiary: #94A3B8;
  --border-color: #E2E8F0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --space-xs: 8px;
  --space-sm: 16px;
  --space-md: 24px;
  --space-lg: 32px;
  --space-xl: 48px;
  --space-2xl: 64px;
  --max-width: 1200px;
  --header-height: 72px;
  color-scheme: light;
}

/* ═══ DARK THEME ═══ */
[data-theme="dark"] {
  --accent: #60A5FA;
  --accent-hover: #93C5FD;
  --accent-light: rgba(96, 165, 250, 0.12);
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-tertiary: #334155;
  --text-primary: #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-tertiary: #64748B;
  --border-color: #334155;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ═══ TYPOGRAPHY ═══ */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  letter-spacing: -0.01em;
}

h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
}

h4 {
  font-size: clamp(1rem, 2vw, 1.125rem);
  font-weight: 500;
}

p {
  font-size: clamp(1rem, 2vw, 1.125rem);
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ═══ SKIP LINK ═══ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--accent);
  color: #fff;
  z-index: 1000;
  font-weight: 500;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  top: 0;
}

/* ═══ CONTAINER ═══ */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-xl);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  min-height: 44px;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  padding: 10px 22px;
}

.btn-secondary:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* ═══ SECTION STYLES ═══ */
.section {
  padding: var(--space-2xl) 0;
}

.section-header {
  text-align: center;
  max-width: 700px;
  margin: 0 auto var(--space-xl);
}

.section-header h2 {
  margin-bottom: var(--space-sm);
}

.section-desc {
  font-size: clamp(1rem, 2vw, 1.125rem);
  color: var(--text-secondary);
}

.section-cta {
  text-align: center;
  margin-top: var(--space-xl);
}

/* ═══ GRID UTILITIES ═══ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

/* ═══ CARD ═══ */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.card img {
  border-radius: var(--radius-md);
  width: 100%;
  object-fit: cover;
}

.card-img-wrapper {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-sm);
  aspect-ratio: 16 / 10;
}

.card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover .card-img-wrapper img {
  transform: scale(1.05);
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.card h3 {
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.card p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.card-icon {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
  line-height: 1;
}

/* ═══ HEADER ═══ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background-color: rgba(255, 255, 255, 0.9);
  transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .site-header {
  background-color: rgba(15, 23, 42, 0.9);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
}

.logo:hover {
  color: var(--accent);
}

.logo-icon {
  font-size: 1.5rem;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-link {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent);
  background: var(--accent-light);
}

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

/* Mobile nav toggle */
.mobile-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  gap: 5px;
  border-radius: var(--radius-sm);
  transition: background 0.3s;
}

.mobile-nav-toggle:hover {
  background: var(--bg-tertiary);
}

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

.hamburger-line {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-nav-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-nav-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-nav-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ═══ HERO ═══ */
.hero {
  position: relative;
  min-height: 80vh;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.7) 0%, rgba(15, 23, 42, 0.3) 100%);
  z-index: 1;
}

.hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-content {
  position: relative;
  z-index: 2;
  color: #fff;
  max-width: 700px;
  padding: var(--space-2xl) var(--space-md);
}

.hero-content h1 {
  color: #fff;
  margin-bottom: var(--space-sm);
}

.hero-subtitle {
  font-size: clamp(1.125rem, 2.5vw, 1.375rem);
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.hero-actions .btn-primary {
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow-md);
}

.hero-actions .btn-primary:hover {
  background: #f0f0f0;
  color: var(--accent-hover);
}

.hero-actions .btn-secondary {
  border-color: rgba(255, 255, 255, 0.8);
  color: #fff;
}

.hero-actions .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ═══ MISSION ═══ */
.mission {
  background: var(--bg-secondary);
}

.mission-card {
  text-align: center;
  align-items: center;
}

.mission-card .card-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-lg);
  font-size: 1.75rem;
  margin-bottom: var(--space-sm);
}

/* ═══ CATALOG ═══ */
.catalog {
  background: var(--bg-primary);
}

.catalog-card h3 {
  margin-top: var(--space-sm);
}

/* ═══ EVENTS ═══ */
.events {
  background: var(--bg-secondary);
}

.event-card {
  flex-direction: row;
  padding: 0;
  overflow: hidden;
}

.event-card .card-img-wrapper {
  width: 40%;
  min-height: 200px;
  margin: 0;
  border-radius: 0;
  aspect-ratio: auto;
}

.event-card .card-body {
  padding: var(--space-md);
}

.event-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--accent-light);
  color: var(--accent);
  margin-bottom: var(--space-xs);
  width: fit-content;
}

.event-meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: auto;
}

.event-meta strong {
  color: var(--text-primary);
}

/* ═══ DIGITAL ═══ */
.digital {
  background: var(--bg-primary);
}

.digital-card {
  text-align: center;
  align-items: center;
}

.digital-card .card-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-lg);
  font-size: 1.75rem;
  margin-bottom: var(--space-sm);
}

/* ═══ KIDS & TEENS ═══ */
.kids {
  background: var(--bg-secondary);
}

.kids-card {
  flex-direction: row;
  padding: 0;
  overflow: hidden;
}

.kids-card .card-img-wrapper {
  width: 40%;
  min-height: 180px;
  margin: 0;
  border-radius: 0;
  aspect-ratio: auto;
}

.kids-card .card-body {
  padding: var(--space-md);
}

/* ═══ SERVICES ═══ */
.services {
  background: var(--bg-primary);
}

.service-card {
  text-align: center;
  align-items: center;
}

.service-card .card-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border-radius: var(--radius-lg);
  font-size: 1.75rem;
  margin-bottom: var(--space-sm);
}

/* ═══ CONTACT ═══ */
.contact {
  background: var(--bg-secondary);
}

.contact-card h3 {
  margin-bottom: var(--space-sm);
}

.contact-card address p {
  margin-bottom: var(--space-xs);
}

.hours-table {
  width: 100%;
  margin-top: var(--space-sm);
  border-collapse: collapse;
}

.hours-table td {
  padding: var(--space-xs) 0;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.hours-table td:last-child {
  text-align: right;
  font-weight: 500;
  color: var(--text-primary);
}

.social-links {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

.social-link {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.social-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}

/* ═══ FOOTER ═══ */
.site-footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-2xl);
}

.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-xl);
  padding-bottom: var(--space-xl);
}

.footer-logo {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.footer-col h4 {
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.footer-col ul li {
  margin-bottom: var(--space-xs);
}

.footer-col ul li a {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.footer-col ul li a:hover {
  color: var(--accent);
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding: var(--space-md) 0;
}

.footer-bottom .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.footer-bottom p {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.photo-credits {
  font-size: 0.75rem;
  line-height: 1.6;
}

.photo-credits a {
  color: var(--text-tertiary);
  text-decoration: underline;
}

.photo-credits a:hover {
  color: var(--accent);
}

/* ═══ THEME TOGGLE ═══ */
.theme-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--bg-primary);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  z-index: 99;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

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

.theme-icon-dark {
  display: none;
}

[data-theme="dark"] .theme-icon-light {
  display: none;
}

[data-theme="dark"] .theme-icon-dark {
  display: inline;
}

/* ═══ FADE-IN SCROLL ANIMATION ═══ */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .fade-in {
    opacity: 1;
    transform: none;
    transition: none;
  }
  html {
    scroll-behavior: auto;
  }
  .card:hover {
    transform: none;
  }
  .btn:hover {
    transform: none;
  }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — 1024px BREAKPOINT
   ═══════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }

  .event-card {
    flex-direction: column;
  }

  .event-card .card-img-wrapper {
    width: 100%;
    min-height: 200px;
  }

  .kids-card {
    flex-direction: column;
  }

  .kids-card .card-img-wrapper {
    width: 100%;
    min-height: 200px;
  }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE — 768px BREAKPOINT
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .nav-list {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-sm);
    gap: var(--space-xs);
    box-shadow: var(--shadow-md);
  }

  .nav-list.open {
    display: flex;
  }

  .nav-link {
    padding: var(--space-sm);
    width: 100%;
    text-align: left;
  }

  .mobile-nav-toggle {
    display: flex;
  }

  .hero {
    min-height: 60vh;
  }

  .hero-content {
    padding: var(--space-xl) var(--space-md);
  }

  .section {
    padding: var(--space-xl) 0;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .footer-bottom .container {
    flex-direction: column;
    text-align: center;
  }

  .contact-grid {
    gap: var(--space-sm);
  }

  .hours-table td {
    font-size: 0.875rem;
  }
}

/* ═══════════════════════════════════════════════════
   SMALL MOBILE — 480px
   ═══════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .container {
    padding: 0 var(--space-sm);
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .card {
    padding: var(--space-sm);
  }

  .theme-toggle {
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
  }
}

/* ═══ INPUT STYLES (for any future form fields) ═══ */
input, textarea, select {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--bg-secondary);
  color: var(--text-primary);
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--text-primary);
}

/* ═══ PRINT ═══ */
@media print {
  .site-header,
  .theme-toggle,
  .mobile-nav-toggle {
    display: none;
  }
  .hero {
    min-height: auto;
  }
  .hero-bg::after {
    display: none;
  }
  .hero-content {
    color: #000;
  }
  .hero-content h1 {
    color: #000;
  }
  .hero-subtitle {
    color: #333;
  }
}

/* Header nav spacing floor (normalizer): keep the brand and the
   menu separated when the flex container runs out of width. */
header nav, header nav > div { gap: 1rem; flex-wrap: wrap; }
@media (max-width: 1280px) { header nav ul { gap: 1rem; } }
