/* Reset & Base */
body {
  background-color: #001e26; /* Darker than Solarized base (for contrast behind article box) */
  color: #d7d7d7; /* Solarized Light Gray Text */
  font-family: Verdana, Geneva, sans-serif;
  font-size: 10pt;
  margin: 0;
  padding: 0;
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

#app-container {
  width: 85%;
  margin: 8px auto;
  background-color: #002b36; /* Dark Solarized Background */
  min-height: 100vh;
}

/* Header (Classic HN Orange) */
.header {
  background-color: #ff6600;
  padding: 2px;
  display: flex;
  align-items: center;
  line-height: 12pt;
}

.header-content {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  font-weight: bold;
  color: #000000; /* Black text on Orange */
  margin-left: 2px;
}

.header-link {
  color: #000000 !important;
  margin-left: 10px;
  text-decoration: none;
}

.header-link.active {
  color: #ffffff !important;
}

/* Story List Styling */
#route-container {
  padding: 8px;
}

.story-item {
  display: flex;
  align-items: baseline;
  margin-bottom: 5px;
  padding: 2px 0;
}

.story-rank {
  color: #888; /* Lighter gray for rank */
  width: 25px;
  text-align: right;
  margin-right: 5px;
  font-size: 10pt;
}

.story-content {
  flex: 1;
}

.story-title {
  margin: 0;
  margin-bottom: 8px;
  font-size: 10pt;
  font-weight: normal;
  display: block;
  line-height: 2.2;
}

.story-title a {
  color: #ffffff; /* Pure white for fresh titles */
  text-decoration: none;
}

.story-title a:visited {
  color: #777777; /* Darker gray for visited */
}

.story-domain {
  font-size: 8pt;
  color: #a0a0a0;
  margin-left: 4px;
}

.story-meta {
  font-size: 7pt;
  color: #a0a0a0;
  margin-top: 8px;
  padding-left: 0;
}

.story-details {
  color: #a0a0a0;
}

/* Article list ruby tags - show all translations */
ruby {
  ruby-position: under;
}

rt {
  user-select: none;
  -webkit-user-select: none;
}

.story-title rt {
  color: #BC510B;
  font-size: 0.65em;
  visibility: visible;
}

/* Compound word separators (the dots between word parts) */
.compound-sep {
  display: inline;
  color: #888;
  margin: 0 -1px; /* Tighter fit for the dot */
  font-weight: normal;
  opacity: 0.7;
}

/* Allow hiding separators via a body class (for future UI toggle) */
body.hide-compound-sep .compound-sep {
  display: none;
}

/* Header Level Picker (3-Level System, centered) */
.header-level-control {
  display: flex;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 3px;
  align-items: center;
  flex-shrink: 0;
}

.header-level-control input[type="radio"] {
  display: none;
}

.header-level-control label {
  padding: 6px 14px;
  font-size: 12px;
  color: #000;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
  text-align: center;
}

.header-level-control input[type="radio"]:checked + label {
  background: #bc510b;
  color: #fff;
}

.header-level-control label:hover:not(:checked) {
  background: rgba(0, 0, 0, 0.05);
}

/* Reader Overlay (Dark Mode) */
#reader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.reader-content {
  background: #002b36;
  color: #d7d7d7;
  width: 90%;
  max-width: 800px;
  height: 90%;
  border: 1px solid #073642;
  border-radius: 2px;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 20px rgba(0,0,0,0.8);
  overflow: hidden; /* Fix: prevent the beam from leaking outside the overlay */
}

.close-reader {
  position: absolute;
  top: 15px;
  right: 25px;
  background: none;
  border: none;
  font-size: 30px;
  line-height: 1;
  height: 44px; /* Enlarged tap target for easier mobile use */
  width: 44px;
  cursor: pointer;
  color: #888;
  z-index: 40; /* Ensure button stays above the toolbar and tripwire */
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-reader:hover {
  color: #fff;
}

/* Tripwire UI (Left Border Control) */
.tripwire-container {
  display: none; /* Hide the tripwire UI but keep the code for easy re-enable */
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 20px;
  width: 16px;
  flex-direction: column;
  z-index: 20;
}

.tripwire-track {
  position: relative;
  height: 100%;
  width: 100%;
}

.tripwire-notch {
  position: absolute;
  left: 0;
  width: 6px;
  height: 20px;
  background: #333;
  cursor: pointer;
  border-radius: 0 4px 4px 0;
  transition: width 0.2s, background 0.2s;
  transform: translateY(-50%);
}

@media (hover: hover) {
  .tripwire-notch:hover {
    width: 10px;
    background: #555;
  }
}

.tripwire-notch.active {
  background: #ff6600;
}

/* Position notches exactly at the percentages defined in JS (handled via inline styles) */
.tripwire-notch {
  /* Default handled in JS, but ensure common styles remain */
}

.tripwire-indicator {
  position: absolute;
  left: 0;
  width: 2px;
  height: 2px;
  background: #ff6600;
  top: 50%;
  transition: top 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 10px #ff6600;
  opacity: 1.0;
  pointer-events: none;
}

/* Solid laser line extending to the right */
.tripwire-indicator::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 800px; /* Long enough to fill the overlay width */
  height: 1px;
  background: rgba(255, 102, 0, 0.4);
  pointer-events: none;
}

.reader-body {
  padding: 50px 30px;
  padding-right: 30px; /* Space for tripwire reclaimed */
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  font-family: Avenir, Montserrat, Corbel, 'URW Gothic', source-sans-pro, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  position: relative;
  
  /* Prevent long German words from overflowing */
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
}

.reader-body h1 {
  font-size: 22px;
  margin-top: 30px;
  margin-bottom: 24px;
  color: #ffffff;
  line-height: 2.4;
  font-weight: 800;
}

.reader-body h2 {
  font-size: 20px;
  margin-top: 2.2em;
  margin-bottom: 0.8em;
  color: #ffffff;
  border-bottom: 1px solid #333;
  padding-bottom: 12px;
  line-height: 2.4;
  font-weight: 700;
}

.reader-body h3 {
  font-size: 18px;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  color: #eeeeee;
  line-height: 2.4;
  font-weight: 700;
}

.reader-body h4, .reader-body h5, .reader-body h6 {
  font-size: 16px;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  color: #dddddd;
  line-height: 2.4;
  font-weight: 600;
}

.reader-body strong, .reader-body b {
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.reader-body a {
  color: #ff6600;
}

.reader-body blockquote {
  border-left: 3px solid #ff6600;
  margin: 20px 0;
  padding-left: 15px;
  color: #d7d7d7;
  font-style: italic;
  background: #073642;
  padding: 10px;
}

.reader-body rt {
  color: #BC510B;
  font-weight: normal;
  font-style: normal;
  transition: opacity 0.3s ease;
  /* Use opacity instead of display to maintain layout stability */
}

.reader-body h1 rt {
  font-size: 0.5em;
}

.reader-body h2 rt,
.reader-body h3 rt,
.reader-body h4 rt,
.reader-body h5 rt,
.reader-body h6 rt {
  font-size: 0.6em;
}

/* Markdown Styles in Reader */
.reader-body p {
  margin-bottom: 1em;
  line-height: 2.8;
}

.reader-body ul, .reader-body ol {
  margin-bottom: 1.5em;
  padding-left: 25px;
}

.reader-body li {
  margin-bottom: 0.8em;
  line-height: 2.8;
}

.reader-body li strong, .reader-body li b {
  color: #fff;
}

.reader-body code {
  background: #073642;
  padding: 1px 2px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.7em;
}

/* Code blocks (pre > code) - internal horizontal scroll only */
.reader-body pre {
  background: #073642;
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  max-width: 100%;
  margin: 16px 0;
}

.reader-body pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 0.85em;
  line-height: 1.5;
  white-space: pre;
}

/* TTS Toggle - iOS-style (same as ruby-toggle was) */
.tts-toggle {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  color: #BC510B;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  height: 26px;
  margin-top: -30px; /* Offset against reader-body padding-top:50px to align with close button top:15px */
  margin-bottom: 20px;
  width: fit-content;
}

/* Hide the default checkbox */
.tts-toggle input[type="checkbox"] {
  display: none;
}

/* The Track (background) */
.tts-fancy-checkbox {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  background: #073642;
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.03s ease;
}

/* The Knob (circle) */
.tts-fancy-checkbox::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: #ccc;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.03s ease, background 0.03s ease;
}

/* Checked State (Accent Background) */
input[type="checkbox"]:checked + .tts-fancy-checkbox {
  background: #BC510B;
}

/* Checked State (Move Knob and lighten) */
input[type="checkbox"]:checked + .tts-fancy-checkbox::after {
  transform: translateX(22px);
  background: #fff;
}

/* Mobile Responsiveness */
@media (max-width: 750px) {
  #app-container {
    width: 100%;
    margin: 0;
  }
  .story-item {
    padding: 5px;
  }

  /* Header adjustments */
  .header-content {
    flex-wrap: wrap;
    justify-content: center;
    padding-bottom: 4px;
  }

  #header-timestamp {
    display: none;
  }

    .header-title {
      width: 100%;
      text-align: center;
      margin-bottom: 6px;
    }
  }
  
  .tts-sentence {
    transition: background-color 0.05s;
    border-radius: 3px;
  }

  /* Only show hover highlight when TTS is enabled */
  @media (hover: hover) {
    .tts-enabled .tts-sentence:hover {
      background-color: rgba(255, 255, 255, 0.1);
      cursor: pointer;
    }
  }

  .tts-sentence.playing {
    background-color: rgba(255, 102, 0, 0.3) !important;
    box-shadow: 0 0 0 2px rgba(255, 102, 0, 0.1);
  }
  
/* Separable Verbs - Blue */
.separable-verb {
  color: #569CD6;
  transition: all 0.2s ease;
  border-radius: 2px;
  cursor: help;
}

.separable-verb.highlight {
  background-color: rgba(86, 156, 214, 0.2);
  box-shadow: 0 0 10px rgba(86, 156, 214, 0.4);
  color: #fff;
  text-shadow: 0 0 8px #569CD6;
}

/* Ruby translations of separable verbs also get blue */
.separable-verb rt {
  color: #569CD6;
}

/* Ruby translations get white with glow when highlighted */
.separable-verb.highlight rt {
  color: #fff;
  text-shadow: 0 0 8px #569CD6;
}

/* --- 3D Paragraph Cubes --- */
.cube-container {
  perspective: 1500px;
  width: 100%;
}

.cube {
  display: grid;
  width: 100%;
  transform-style: preserve-3d;
  /* translateZ moves the rotation origin backwards */
  transform: translateZ(calc(var(--cube-half-width, 0px) * -1)) rotateY(0deg);
  cursor: grab;
  /* Prevent text selection while dragging */
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.cube:active {
  cursor: grabbing;
}

.cube.cube-snap {
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cube-face {
  grid-area: 1 / 1;
  width: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Numeric faces for dynamic configuration */
.cube-face-0 {
  transform: rotateY(0deg) translateZ(var(--cube-half-width, 0px));
}

.cube-face-1 {
  transform: rotateY(90deg) translateZ(var(--cube-half-width, 0px));
}

.cube-face-2 {
  transform: rotateY(180deg) translateZ(var(--cube-half-width, 0px));
}

.cube-face-3 {
  transform: rotateY(270deg) translateZ(var(--cube-half-width, 0px));
}

/* Strip margins inside faces so they don't break layout unexpectedly */
.cube-face * {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* Prevent image/link ghost dragging while interacting with cubes */
.cube-face a, .cube-face img {
  -webkit-user-drag: none;
  user-select: none;
}

.title-cube-container {
  margin-bottom: 8px; /* Maintain the spacing for title */
}
