@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

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

body {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  background: #0a0a0a;
  color: #d4d4d4;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0a0a0a;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #2a2a2a;
}

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

header h1 {
  font-size: 16px;
  font-weight: 700;
  color: #00ff88;
  letter-spacing: 2px;
  text-transform: uppercase;
}

header h1::before {
  content: '> ';
  color: #555;
}

#tagline {
  display: block;
  font-size: 9px;
  font-weight: 400;
  color: #444;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 2px;
  padding-left: 18px; /* align under title text, past the '> ' */
}

.toggles {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  background: none;
  border: 1px solid #2a2a2a;
  color: #555;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
  text-decoration: none;
}

.toggle-btn.active {
  color: #00ff88;
  border-color: #00ff8844;
}

.toggle-btn .tts-waves { opacity: 0.3; }
.toggle-btn.active .tts-waves { opacity: 1; }

#status {
  font-size: 11px;
  color: #555;
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* Per-card speak button */
.speak-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.speak-btn:hover { color: #00ff88; }
.speak-btn.speaking { color: #00ff88; }

.share-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.2s;
  font-size: 10px;
  font-family: inherit;
}
.share-btn:hover { color: #00ff88; }

main {
  position: relative;
  height: calc(100dvh - 150px);
  min-height: 260px;
  max-width: 600px;
  margin: 12px 16px 0;
}

@media (min-width: 632px) {
  main { margin: 12px auto 0; }
}

/* Cards */
.card {
  position: absolute;
  inset: 0;
  background: #111;
  border: 1px solid #2a2a2a;
  overflow-y: auto;
  touch-action: pan-y;
  user-select: none;
  cursor: grab;
}

.card.dragging {
  cursor: grabbing;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
}

[data-category="history"] .card::before,
[data-category="history"]::before { background: #ff6b2b; }
[data-category="architecture"] .card::before,
[data-category="architecture"]::before { background: #00a8ff; }
[data-category="culture"] .card::before,
[data-category="culture"]::before { background: #00ff88; }
[data-category="art"] .card::before,
[data-category="art"]::before { background: #d946ef; }
[data-category="nature"] .card::before,
[data-category="nature"]::before { background: #22d3ee; }

/* Use ::before on the card itself since data-category is on article */
.card[data-category="history"]::before { background: #ff6b2b; }
.card[data-category="architecture"]::before { background: #00a8ff; }
.card[data-category="culture"]::before { background: #00ff88; }
.card[data-category="art"]::before { background: #d946ef; }
.card[data-category="nature"]::before { background: #22d3ee; }

.card-img {
  width: 100%;
  height: 180px;
  background-size: cover;
  background-position: center;
  background-color: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
  filter: grayscale(30%) contrast(1.1);
}

.card-body {
  padding: 14px 16px;
}

.card-category {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 2px 6px;
  margin-bottom: 8px;
  border: 1px solid;
}

.card[data-category="history"] .card-category { color: #ff6b2b; border-color: #ff6b2b33; }
.card[data-category="architecture"] .card-category { color: #00a8ff; border-color: #00a8ff33; }
.card[data-category="culture"] .card-category { color: #00ff88; border-color: #00ff8833; }
.card[data-category="art"] .card-category { color: #d946ef; border-color: #d946ef33; }
.card[data-category="nature"] .card-category { color: #22d3ee; border-color: #22d3ee33; }

.card h2 {
  font-size: 15px;
  font-weight: 700;
  color: #eee;
  margin-bottom: 8px;
  line-height: 1.4;
}

.card p {
  font-size: 13px;
  line-height: 1.6;
  color: #999;
  margin-bottom: 12px;
}

.card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  padding-top: 8px;
  border-top: 1px solid #1a1a1a;
}

.card .dist {
  color: #555;
}

.card .dist::before {
  content: '~ ';
}

.card a {
  color: #00ff88;
  text-decoration: none;
  font-weight: 500;
}

.card a::before {
  content: '[';
  color: #555;
}

.card a::after {
  content: ']';
  color: #555;
}

.card a:hover {
  color: #fff;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Loading skeletons */
.skeleton {
  animation: pulse 1.5s ease-in-out infinite;
  background: #111;
  border: 1px solid #2a2a2a;
}

.skeleton-img {
  width: 100%;
  height: 180px;
  background: #1a1a1a;
}

.skeleton-text {
  height: 12px;
  background: #1a1a1a;
  margin: 14px 16px;
}

.skeleton-text.short {
  width: 60%;
  margin-top: 8px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hidden {
  display: none !important;
}

/* Swipe hints */
.swipe-hint {
  position: absolute;
  top: 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.05s;
}
.swipe-hint-skip { left: 12px; color: #ff4444; border-color: #ff4444; }
.swipe-hint-save { right: 12px; color: #00ff88; border-color: #00ff88; }

/* Deck done / empty */
.deck-done {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #333;
  font-size: 12px;
  line-height: 2;
  pointer-events: none;
}

/* Progress dots */
#dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 10px 16px 6px;
  max-width: 600px;
  margin: 0 auto;
  min-height: 21px;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #222;
  transition: background 0.2s;
  flex-shrink: 0;
}
.dot-active  { background: #00ff88; }
.dot-seen    { background: #1c1c1c; }
.dot-saved   { background: #00ff8844; }

/* Saved button badge */
#saved-btn { position: relative; }
#saved-count {
  position: absolute;
  top: 2px;
  right: 1px;
  font-size: 8px;
  color: #00ff88;
  line-height: 1;
  pointer-events: none;
}

/* Saved panel */
#saved-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(2px);
}
#saved-panel-inner {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 75vh;
  background: #0f0f0f;
  border-top: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
}
#saved-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #1a1a1a;
  flex-shrink: 0;
}
#saved-panel-header span {
  color: #00ff88;
  font-size: 12px;
  letter-spacing: 1px;
}
#saved-close {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 20px;
  padding: 0;
  line-height: 1;
  font-family: inherit;
}
#saved-close:hover { color: #eee; }
#saved-list { overflow-y: auto; flex: 1; }

.saved-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #1a1a1a;
  align-items: flex-start;
}
.saved-item-body { flex: 1; min-width: 0; }
.saved-item-title {
  font-size: 12px;
  font-weight: 700;
  color: #ddd;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-item-blurb {
  font-size: 11px;
  color: #555;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.saved-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.saved-item-remove {
  background: none;
  border: none;
  color: #333;
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  font-family: inherit;
}
.saved-item-remove:hover { color: #ff4444; }
.saved-item-link {
  font-size: 10px;
  color: #00ff88;
  text-decoration: none;
}
.saved-item-link::before { content: '['; color: #555; }
.saved-item-link::after  { content: ']'; color: #555; }
.saved-item-link:hover   { color: #fff; }
.saved-empty {
  text-align: center;
  padding: 40px 20px;
  color: #333;
  font-size: 12px;
  line-height: 2;
}

/* Gate modal */
#gate-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#gate-modal.hidden { display: none; }

@media (min-width: 540px) {
  #gate-modal { align-items: center; }
}

#gate-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(3px);
}

#gate-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  background: #0f0f0f;
  border: 1px solid #2a2a2a;
  border-bottom: none;
}

@media (min-width: 540px) {
  #gate-inner { border: 1px solid #2a2a2a; margin: 16px; }
}

#gate-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #1a1a1a;
}

#gate-title {
  font-size: 11px;
  color: #00ff88;
  letter-spacing: 1px;
}

#gate-close {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  font-family: inherit;
  padding: 0;
}
#gate-close:hover { color: #eee; }

#gate-body { padding: 20px 16px 24px; }

#gate-lead {
  font-size: 13px;
  color: #ccc;
  margin-bottom: 14px;
  line-height: 1.6;
}
#gate-lead strong { color: #00ff88; font-weight: 700; }

#gate-props {
  list-style: none;
  margin-bottom: 20px;
}
#gate-props li {
  font-size: 11px;
  color: #555;
  line-height: 2.2;
  letter-spacing: 0.5px;
}

#gate-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

#gate-email {
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  color: #d4d4d4;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
}
#gate-email:focus { border-color: #00ff8866; }
#gate-email::placeholder { color: #333; }

#gate-cta {
  background: #00ff8814;
  border: 1px solid #00ff8844;
  color: #00ff88;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
#gate-cta:hover { background: #00ff8826; border-color: #00ff8888; }

#gate-dismiss {
  background: none;
  border: none;
  color: #333;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.5px;
  cursor: pointer;
  padding: 0;
  width: 100%;
  text-align: center;
  transition: color 0.2s;
}
#gate-dismiss:hover { color: #666; }

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

/* Scanline overlay for extra retro feel */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  z-index: 100;
}
