:root {
  /* Light Theme (default) */
  --color-bg: #FAF9F5;
  --color-text: #1F1E1D;
  --color-text-muted: #878680;
  --color-toggle: #1F1E1D;
}

/* Logo styling */
.logo {
  filter: brightness(0) invert(0); /* Black logo by default */
  transition: filter 0.3s ease;
}

[data-theme="dark"] .logo {
  filter: brightness(0) invert(1); /* White logo in dark mode */
}

/* Dark Theme */
[data-theme="dark"] {
  --color-bg: #1F1E1D;
  --color-text: #FAF9F5;
  --color-text-muted: #878680;
  --color-toggle: #FAF9F5;
}

*, *::before, *::after {
    box-sizing: border-box;
}

/* Player and Toggle Container */
.player-toggle-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Theme Toggle Container */
.theme-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1; /* normalize line-height for consistent vertical centering */
}

.theme-text {
    color: var(--color-text-muted);
    font-size: 14px;
    font-family: 'EB Garamond', serif;
    white-space: nowrap;
}

/* Dark Mode Toggle */
#dark-mode-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#dark-mode-switch {
    width: 15px;
    height: 15px;
    background-color: var(--color-toggle);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

/* Music Player Styles */
#music-player {
    background-color: transparent;
    transition: background-color 0.3s ease, transform 0.2s ease;
    user-select: none;
    display: inline-flex;
    align-items: center;
    height: 20px;
    position: relative;
    line-height: 1; /* keep control cluster aligned to the same cap-height */
}

/* Song Title Styles */
#song-title {
    font-family: 'EB Garamond', serif;
    font-size: 0.9em;
    color: var(--color-text-muted);
    /* container should not force truncation; the inner span will handle it */
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    max-width: 200px;
    transition: color 0.2s ease;
    opacity: 1 !important; /* Ensure it's always visible */
    line-height: 1; /* match Theme label line-height for alignment */
    position: relative; /* for scrub bar positioning */
    cursor: default;
    display: inline-flex; /* participate in flex baseline and center children */
    align-items: center; /* vertically center text and scrub UI */
    vertical-align: middle;
}

/* keep title text truncate behavior but allow us to fully cover it */
#song-title .song-title-text {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#song-title.playing {
    color: var(--color-text-muted);
}

/* Hide the text when scrub bar is shown; scrub bar replaces the title */
#song-title.hovering .song-title-text,
#song-title.touch-active .song-title-text,
#song-title.playing:hover .song-title-text {
    visibility: hidden; /* keep width to avoid layout shift */
    text-overflow: clip; /* prevent ellipsis from peeking through */
}

/* Scrub bar */
#scrub-bar {
    /* overlay the title text in the same row and same width */
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0; /* fill the #song-title content box */
    display: none; /* hidden by default */
    pointer-events: none; /* enable only when active */
    overflow: visible; /* ensure thumb not clipped */
}

#song-title.hovering #scrub-bar,
#song-title.touch-active #scrub-bar {
    display: block;
    pointer-events: auto;
}

/* Hard-disable scrub bar on touch devices so the title never disappears */
@media (pointer: coarse) {
  #song-title.touch-active .song-title-text,
  #song-title.playing:hover .song-title-text,
  #song-title.hovering .song-title-text {
    /* keep the title visible on mobile */
    visibility: visible !important;
    text-overflow: ellipsis !important;
  }

  #song-title.touch-active #scrub-bar,
  #song-title.playing:hover #scrub-bar,
  #song-title.hovering #scrub-bar {
    display: none !important;
    pointer-events: none !important;
  }
}

#scrub-bar .scrub-track {
    position: absolute;
    /* add internal gutters so the round thumb isn't clipped at ends */
    left: 6px;
    right: 6px;
    top: 50%; /* vertically center over the hidden text */
    height: 2px;
    background: var(--color-text-muted); /* simple line in muted color */
    transform: translateY(-50%);
    border-radius: 2px;
    opacity: 0.9;
}

#scrub-bar .scrub-thumb {
    position: absolute;
    top: 50%;
    width: 8px;
    height: 8px;
    background: var(--color-toggle); /* round indicator in toggle color */
    border-radius: 50%;
    transform: translate(-50%, -50%);
    left: 6px; /* start aligned with left gutter */
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-bg) 85%, transparent);
    pointer-events: none; /* let bar receive events */
}

/* Hover behavior for non-touch */
@media (hover: hover) and (pointer: fine) {
  #song-title.playing:hover {
    cursor: pointer;
  }
  #song-title.playing:hover #scrub-bar {
    display: block;
    pointer-events: auto;
  }
}

/* Ensure scrub UI spans full available width inside title box without clipping */
#scrub-bar .scrub-track,
#scrub-bar .scrub-thumb {
    contain: layout paint size;
}

#track-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 100%;
}

/* Add SVG filter for drop shadow */
.player-button svg {
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.player-button {
    background: var(--color-toggle);
    border: none;
    color: var(--color-bg);
    cursor: pointer;
    padding: 1px;
    transition: background-color 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    margin: 0 2px;
}

.player-button svg {
    width: 100%;
    height: 100%;
    display: block;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: 'EB Garamond', serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    transition: background-color 0.3s ease, color 0.3s ease;
}
.container {
    height: 100vh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.container::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.container {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.page {
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    overflow: hidden; /* keep each page self-contained */
}

/* Font size for pages */
.page p {
    font-size: 1.2em;
}

#ascii-art-container {
    position: relative;
    width: 60%;
    height: 60%;
    justify-items: center;          /* center children horizontally */
    align-content: center;          /* center the grid block vertically */
    transition: transform 0.5s ease-out;
}
#ascii-art {
    white-space: pre;
    font-family: monospace; /* Keep monospace for ASCII art */
    /* Responsive scaling: smaller on very small viewports, grows but capped */
    font-size: clamp(6px, 1.1vw, 11px);
    line-height: 0.9;
    text-align: center;
    cursor: default;
    user-select: none;
    display: block;
    grid-row: 1 / 2;
    justify-self: center;
    max-width: 100%;
    overflow: hidden;               /* prevent spill */
}

#page2 {
    font-size: clamp(1.2em, 4vw, 1.7em);
    padding: 1em;
    text-align: center;
}

#footer {
    position: static;
    width: 100%;
    background: transparent;
    text-align: center;
    z-index: 1;
    font-family: 'EB Garamond', serif;
    /* Slightly smaller cap for tighter layouts */
    font-size: clamp(0.78em, 1.8vw, 0.95em);
    color: var(--color-text);
    justify-self: center;
    clear: both;
    display: block;
}

/* removed unused visibility transition */

#footer a {
    color: var(--color-text);
    text-decoration: none;
}

#footer a:hover {
    text-decoration: none;
}

.category-link {
    margin: 0 10px;
    text-decoration: none;
    color: var(--color-text);
    position: relative;
    padding-bottom: 2px;
    transition: color 0.3s ease;
}

@media (hover: hover) {
    .category-link:hover {
        color: var(--color-text);
    }
}
.category-link.active {
    color: var(--color-text);
}

.category-link.active {
    font-weight: 500;
}

.category-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--color-text);
    animation: underline 0.3s ease-out;
}

@keyframes underline {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

/* Header Styles */
#main-header {
    position: fixed;
    top: -100px; /* Start off-screen */
    left: 0;
    width: 100%;
    background-color: var(--color-bg);
    z-index: 1000;
    padding: 0.5em 0;
    transition: top 0.3s ease-in-out;
    opacity: 0;
    visibility: hidden;
}

#main-header.visible {
    top: 0;
    opacity: 1;
    visibility: visible;
}

.header-content {
    display: flex;
    align-items: center;
    /*max-width: 1200px;*/
    /*margin: 0 auto;*/
    padding: 0 1em;
}

.logo-container {
    margin-right: 1.5em;
    display: none;
}

.logo {
    height: 35px;
    width: auto;
    display: block;
}

.categories-nav {
    flex: 1;
    overflow: hidden;
}

.categories-scroll {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    padding: 0.5em 0;
}

.categories-scroll::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.category-link {
    white-space: nowrap;
    margin-right: 1.5em;
    color: var(--color-text-muted);
    text-decoration: none;
    font-family: 'EB Garamond', serif;
    font-size: 0.9em;
    padding: 0.3em 0;
    position: relative;
    transition: color 0.2s ease;
}

.category-link.active {
    color: var(--color-text);
}

@media (hover: hover) {
    .category-link:hover {
        color: var(--color-text);
    }
}

.category-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: 0;
    left: 0;
    background-color: var(--color-text);
    transition: width 0.3s ease;
}

.category-link.active::after {
    width: 100%;
}

@media (hover: hover) {
    .category-link:hover::after {
        width: 100%;
    }
}



/* Page specific styles */
.page {
    min-height: 100vh;
    padding: 1em;
    box-sizing: border-box;
    max-width: 800px; 
    margin: 0 auto;
}
