/* ==============================================================================
   history.devpy.eu — Homepage UX Redesign (Codex Historiae Portal)
   Strictly following prototype: dejiny_v_s_vislostiach_ux_redizajn.html
   100% Offline, Self-Contained CSS (Zero external Tailwind CDN)
   ============================================================================== */

:root {
  /* Light Mode Variables - Parchment & Brass */
  --bg-primary: #EDE3D2;
  --bg-secondary: #E2D4BC;
  --surface-glow: rgba(248, 243, 234, 0.90);
  --surface-solid: #F8F3EA;
  --surface-subtle: rgba(237, 227, 210, 0.88);
  --text-primary: #1A1612;
  --text-secondary: #524538;
  --brass-main: #B88924;
  --brass-line: rgba(184, 137, 36, 0.38);
  --crimson-main: #9B2323;
  --emerald-main: #065f46;
  --damascus-main: #243447;
  --radial-aura: radial-gradient(circle at 50% 14%, rgba(255, 250, 238, 0.82) 0%, rgba(237, 227, 210, 0.25) 55%, transparent 100%);

  /* Font Families */
  --font-display: 'Cinzel', serif;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html.dark {
  /* Dark Mode Variables - Damascus Steel & Gold */
  --bg-primary: #0E131A;
  --bg-secondary: #141B24;
  --surface-glow: rgba(27, 36, 48, 0.88);
  --surface-solid: #1B2430;
  --surface-subtle: rgba(20, 27, 36, 0.92);
  --text-primary: #F3EDE2;
  --text-secondary: #B4C0D0;
  --brass-main: #D4AF37;
  --brass-line: rgba(212, 175, 55, 0.36);
  --crimson-main: #C83737;
  --emerald-main: #10b981;
  --damascus-main: #6384A6;
  --radial-aura: radial-gradient(circle at 50% 14%, rgba(212, 175, 55, 0.14) 0%, rgba(20, 27, 36, 0.45) 55%, transparent 100%);
}

/* Base Body Styles */
body.portal-bg {
  background-color: var(--bg-primary) !important;
  background-image: var(--radial-aura) !important;
  background-attachment: fixed;
  color: var(--text-primary) !important;
  transition: background-color 0.35s ease, color 0.35s ease;
  font-family: var(--font-sans);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Hide legacy navbar on homepage in favor of Chamfer Header */
body.portal-bg #navbar {
  display: none !important;
}

/* ==============================================================================
   Core Geometric Components
   ============================================================================== */

/* Chamfer Card */
.chamfer-card {
  clip-path: polygon(20px 0%, calc(100% - 20px) 0%, 100% 20px, 100% calc(100% - 20px), calc(100% - 20px) 100%, 20px 100%, 0% calc(100% - 20px), 0% 20px);
  background: var(--surface-glow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid var(--brass-line);
}

/* Architectural Arch Portal Cards */
.arch-portal-card {
  border-radius: 64px 64px 24px 24px;
  background: linear-gradient(180deg, var(--surface-solid) 0%, var(--surface-subtle) 100%);
  border: 1.5px solid var(--brass-line);
  box-shadow: 0 18px 42px -14px rgba(26, 22, 18, 0.11), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

html.dark .arch-portal-card {
  background: linear-gradient(180deg, rgba(29, 39, 52, 0.95) 0%, rgba(18, 25, 34, 0.92) 100%);
  box-shadow: 0 20px 50px -15px rgba(0, 0, 0, 0.68), inset 0 1px 0 rgba(212, 175, 55, 0.22);
}

/* Bring card contents above pseudo-elements */
.arch-portal-card > * {
  position: relative;
  z-index: 10;
}

/* Base Pseudo-element for hover gradients */
.arch-portal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 1;
}

/* Hover Elevation & Focus State */
.arch-portal-card:hover,
.arch-portal-card.is-focused {
  transform: translateY(-6px);
  border-color: var(--brass-main);
}

/* Card I: Crimson Tint */
.card-tint-crimson::before {
  background: linear-gradient(180deg, rgba(155, 35, 35, 0.04) 0%, rgba(155, 35, 35, 0.14) 100%);
}
html.dark .card-tint-crimson::before {
  background: linear-gradient(180deg, rgba(200, 55, 55, 0.06) 0%, rgba(200, 55, 55, 0.18) 100%);
}
.card-tint-crimson:hover::before,
.card-tint-crimson.is-focused::before {
  opacity: 1;
}

/* Card II: Emerald Tint */
.card-tint-emerald::before {
  background: linear-gradient(180deg, rgba(6, 95, 70, 0.04) 0%, rgba(6, 95, 70, 0.14) 100%);
}
html.dark .card-tint-emerald::before {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.06) 0%, rgba(16, 185, 129, 0.18) 100%);
}
.card-tint-emerald:hover::before,
.card-tint-emerald.is-focused::before {
  opacity: 1;
}

/* Card III: Damascus Tint */
.card-tint-damascus::before {
  background: linear-gradient(180deg, rgba(36, 52, 71, 0.05) 0%, rgba(36, 52, 71, 0.15) 100%);
}
html.dark .card-tint-damascus::before {
  background: linear-gradient(180deg, rgba(99, 132, 166, 0.06) 0%, rgba(99, 132, 166, 0.20) 100%);
}
.card-tint-damascus:hover::before,
.card-tint-damascus.is-focused::before {
  opacity: 1;
}

/* Decorative Medallion */
.diamond-medallion {
  transform: rotate(45deg);
  border: 1.5px solid var(--brass-main);
}
.diamond-medallion > * {
  transform: rotate(-45deg);
}

/* ==============================================================================
   Button Components
   ============================================================================== */

.btn-mirage-primary {
  clip-path: polygon(14px 0%, calc(100% - 14px) 0%, 100% 50%, calc(100% - 14px) 100%, 14px 100%, 0% 50%);
  background: linear-gradient(135deg, #A82626 0%, #7C1818 100%);
  color: #FFF8EC !important;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.85rem 1.9rem;
  box-shadow: 0 10px 25px -5px rgba(155, 35, 35, 0.5);
  transition: all 0.22s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  text-decoration: none;
  cursor: pointer;
  border: none;
}
.btn-mirage-primary:hover {
  background: linear-gradient(135deg, #C22F2F 0%, #941E1E 100%);
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 14px 28px -4px rgba(155, 35, 35, 0.6);
}

.btn-mirage-primary.btn-emerald {
  background: linear-gradient(135deg, #065f46 0%, #022c22 100%);
  box-shadow: 0 10px 25px -5px rgba(6, 95, 70, 0.5);
}
.btn-mirage-primary.btn-emerald:hover {
  background: linear-gradient(135deg, #047857 0%, #064e3b 100%);
  box-shadow: 0 14px 28px -4px rgba(6, 95, 70, 0.6);
}

.btn-mirage-primary.btn-damascus {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  box-shadow: 0 10px 25px -5px rgba(30, 41, 59, 0.5);
}
.btn-mirage-primary.btn-damascus:hover {
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  box-shadow: 0 14px 28px -4px rgba(30, 41, 59, 0.6);
}

.btn-mirage-brass {
  clip-path: polygon(12px 0%, calc(100% - 12px) 0%, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0% 50%);
  background: linear-gradient(180deg, var(--surface-solid) 0%, var(--bg-secondary) 100%);
  border: 1.5px solid var(--brass-main);
  color: var(--text-primary) !important;
  font-family: var(--font-sans);
  font-weight: 700;
  padding: 0.7rem 1.45rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  cursor: pointer;
}
.btn-mirage-brass:hover {
  background: linear-gradient(135deg, #C59B27 0%, #9E7818 100%);
  color: #130F0A !important;
}

/* Chapter Pill Selector in Hero */
.chapter-tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.95rem;
  border-radius: 9999px;
  border: 1.5px solid var(--brass-line);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}
.chapter-tab-pill:hover,
.chapter-tab-pill.is-active {
  border-color: var(--brass-main);
  color: var(--text-primary);
  background: var(--surface-solid);
  box-shadow: 0 4px 12px -2px rgba(184, 137, 36, 0.22);
}
.chapter-tab-pill .tab-indicator {
  font-size: 0.6rem;
  color: var(--crimson-main);
}

/* ==============================================================================
   Astrolabe Keyframe Animations & Compatibility Hooks
   ============================================================================== */

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes spinReverseSlow {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

@keyframes rotateSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes rotateReverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.astrolabe-ring-cw {
  animation: spinSlow 90s linear infinite;
  transform-origin: 200px 200px;
}

.astrolabe-ring-ccw {
  animation: spinReverseSlow 120s linear infinite;
  transform-origin: 200px 200px;
}

.spin-slow {
  animation: rotateSlow 80s linear infinite;
  transform-origin: 240px 240px;
}

.spin-rev {
  animation: rotateReverse 110s linear infinite;
  transform-origin: 240px 240px;
}

.emblem-enter {
  animation: fadeInScale 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Strict reduced-motion accessibility rules (asserted by test_r1_5) */
@media (prefers-reduced-motion: reduce) {
  .astrolabe-ring-cw,
  .astrolabe-ring-ccw,
  .spin-slow,
  .spin-rev,
  .emblem-enter {
    animation: none !important;
  }
}

/* ==============================================================================
   Self-Contained Utility Classes (Zero External Tailwind Dependency)
   ============================================================================== */

/* Font utility families */
.font-display { font-family: var(--font-display); }
.font-serif { font-family: var(--font-serif); }
.font-sans { font-family: var(--font-sans); }
.font-mono { font-family: var(--font-mono); }

/* Font weights */
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Font sizes & leading */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-5xl { font-size: 3rem; line-height: 1.15; }
.text-6xl { font-size: 3.75rem; line-height: 1.15; }

.leading-none { line-height: 1; }
.leading-relaxed { line-height: 1.625; }
.tracking-wide { letter-spacing: 0.025em; }
.tracking-wider { letter-spacing: 0.05em; }
.tracking-widest { letter-spacing: 0.1em; }
.uppercase { text-transform: uppercase; }
.italic { font-style: italic; }
.text-center { text-align: center; }

/* Text colors */
.text-\[color\:var\(--text-primary\)\] { color: var(--text-primary) !important; }
.text-\[color\:var\(--text-secondary\)\] { color: var(--text-secondary) !important; }
.text-\[color\:var\(--crimson-main\)\] { color: var(--crimson-main) !important; }
.text-\[color\:var\(--brass-main\)\] { color: var(--brass-main) !important; }
.text-\[color\:var\(--damascus-main\)\] { color: var(--damascus-main) !important; }
.bg-\[color\:var\(--bg-secondary\)\] { background-color: var(--bg-secondary) !important; }
.border-\[color\:var\(--brass-line\)\] { border-color: var(--brass-line) !important; }
.border-\[color\:var\(--brass-main\)\] { border-color: var(--brass-main) !important; }
.hover\:border-\[color\:var\(--brass-main\)\]:hover { border-color: var(--brass-main) !important; }
.hover\:text-\[color\:var\(--text-primary\)\]:hover { color: var(--text-primary) !important; }
.hover\:text-\[color\:var\(--crimson-main\)\]:hover { color: var(--crimson-main) !important; }

/* Prevent browser default purple :visited link color across portal */
body.portal-bg a,
body.portal-bg a:visited {
  color: inherit;
}
.brand-header-link,
.brand-header-link:visited,
.brand-header-link:hover,
.brand-header-link:active,
.brand-header-link .brand-title {
  color: var(--text-primary) !important;
  text-decoration: none !important;
}
.brand-header-link .brand-subtitle {
  color: var(--text-secondary) !important;
}

.text-amber-50 { color: #FFFBEB; }
.text-amber-200 { color: #FDE68A; }
.text-amber-300 { color: #FCD34D; }
.text-emerald-50 { color: #ECFDF5; }
.text-slate-100 { color: #F1F5F9; }
.text-white, .\!text-white { color: #FFFFFF !important; }

/* Positioning & Layout */
.fixed { position: fixed; }
.absolute { position: absolute; }
.relative { position: relative; }
.sticky { position: sticky; }
.top-4 { top: 1rem; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.-top-48 { top: -12rem; }
.-right-48 { right: -12rem; }
.top-\[42\%\] { top: 42%; }
.-left-56 { left: -14rem; }
.top-1\/2 { top: 50%; }
.left-1\/2 { left: 50%; }
.-translate-x-1\/2 { transform: translateX(-50%); }
.-translate-y-1\/2 { transform: translateY(-50%); }

.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-50 { z-index: 50; }

.pointer-events-none { pointer-events: none; }
.overflow-hidden { overflow: hidden; }

/* Containers */
.max-w-2xl { max-w: 42rem; max-width: 42rem; }
.max-w-4xl { max-width: 56rem; }
.max-w-6xl { max-width: 72rem; }
.max-w-7xl { max-width: 80rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.min-h-\[55vh\] { min-height: 55vh; }

/* Flexbox */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.shrink-0 { flex-shrink: 0; }
.whitespace-nowrap { white-space: nowrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* Grid */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }

/* Gaps & Spacing */
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-2\.5 { gap: 0.625rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-8 { gap: 2rem; }

.space-y-2\.5 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.625rem; }
.space-y-6 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.5rem; }

/* Dimensions */
.w-full { width: 100%; }
.w-2\.5 { width: 0.625rem; }
.h-2\.5 { height: 0.625rem; }
.w-3\.5 { width: 0.875rem; }
.h-3\.5 { height: 0.875rem; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }
.w-5 { width: 1.25rem; }
.h-5 { height: 1.25rem; }
.w-10 { width: 2.5rem; }
.h-10 { height: 2.5rem; }
.h-px { height: 1px; }

.w-\[640px\] { width: 640px; }
.h-\[640px\] { height: 640px; }
.w-\[760px\] { width: 760px; }
.h-\[760px\] { height: 760px; }
.w-\[480px\] { width: 480px; }
.h-\[480px\] { height: 480px; }

/* Padding & Margins */
.p-1 { padding: 0.25rem; }
.p-4 { padding: 1rem; }
.p-7 { padding: 1.75rem; }
.pt-2 { padding-top: 0.5rem; }
.pt-4 { padding-top: 1rem; }
.pt-12 { padding-top: 3rem; }
.pt-16 { padding-top: 4rem; }
.pb-4 { padding-bottom: 1rem; }
.pb-20 { padding-bottom: 5rem; }
.px-2\.5 { padding-left: 0.625rem; padding-right: 0.625rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
.py-2\.5 { padding-top: 0.625rem; padding-bottom: 0.625rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-3\.5 { padding-top: 0.875rem; padding-bottom: 0.875rem; }
.py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2\.5 { margin-bottom: 0.625rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mt-1 { margin-top: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }

/* Borders & Rounding */
.border { border-width: 1px; border-style: solid; }
.border-t { border-top-width: 1px; border-top-style: solid; }
.rounded-full { border-radius: 9999px; }
.rounded-2xl { border-radius: 1rem; }

/* Shadows, Opacity & Transforms */
.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
.drop-shadow-sm { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.05)); }

.opacity-20 { opacity: 0.2; }
.opacity-25 { opacity: 0.25; }
.opacity-80 { opacity: 0.8; }
.rotate-45 { transform: rotate(45deg); }

.transition-all { transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-colors { transition-property: color, background-color, border-color; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
.transition-transform { transition-property: transform; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }

.block { display: block; }
.hidden { display: none; }

/* Group hover */
.group:hover .group-hover\:scale-110 {
  transform: rotate(45deg) scale(1.1);
}

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

/* ==============================================================================
   Responsive Media Queries
   ============================================================================== */

@media (min-width: 640px) {
  .sm\:inline { display: inline; }
  .sm\:flex-row { flex-direction: row; }
  .sm\:px-8 { padding-left: 2rem; padding-right: 2rem; }
  .sm\:p-9 { padding: 2.25rem; }
  .sm\:py-3\.5 { padding-top: 0.875rem; padding-bottom: 0.875rem; }
  .sm\:pt-24 { padding-top: 6rem; }
  .sm\:pb-28 { padding-bottom: 7rem; }
  .sm\:text-sm { font-size: 0.875rem; line-height: 1.25rem; }
  .sm\:text-lg { font-size: 1.125rem; line-height: 1.75rem; }
  .sm\:text-xl { font-size: 1.25rem; line-height: 1.75rem; }
  .sm\:text-6xl { font-size: 3.75rem; line-height: 1.15; }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .xl\:text-\[64px\] { font-size: 64px; line-height: 1.15; }
  .xl\:gap-10 { gap: 2.5rem; }
}

.portal-chapter-grid {
  grid-template-columns: minmax(0, 1fr);
}

.portal-event-link {
  color: var(--text-primary);
  text-underline-offset: 0.2em;
}

@media (min-width: 900px) {
  .portal-chapter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
