@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400;1,700&family=Merriweather:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700&family=Courier+Prime:wght@400;700&display=swap');

:root {
  /* Paper Tones */
  --paper-50: #fdfbf7;
  --paper-100: #f9f4e6;
  --paper-200: #f0e6cc;
  --paper-300: #e6d5aa;
  --paper-400: #dcc488;
  --paper-500: #d2b46e;
  --paper-600: #a89058;
  --paper-700: #7e6c42;
  --paper-800: #54482c;
  --paper-900: #2a2416;

  /* Ink Colors */
  --ink-50: #f2f2f2;
  --ink-100: #d9d9d9;
  --ink-200: #bfbfbf;
  --ink-300: #a6a6a6;
  --ink-400: #8c8c8c;
  --ink-500: #737373;
  --ink-600: #595959;
  --ink-700: #404040;
  --ink-800: #262626;
  --ink-900: #1a1a1a;
  --ink-950: #0d0d0d;

  /* Tech Accents */
  --tech-cyan: #00f3ff;
  --tech-magenta: #ff00ff;
  --tech-yellow: #ffff00;

  /* Semantic */
  --bg-primary: var(--paper-100);
  --bg-secondary: var(--paper-200);
  --bg-tertiary: var(--paper-300);
  --text-primary: var(--ink-900);
  --text-secondary: var(--ink-700);
  --text-inverse: var(--paper-100);

  --border-light: var(--paper-300);
  --border-medium: var(--paper-400);
  --border-dark: var(--ink-800);

  --shadow-sm: 2px 2px 0px rgba(0, 0, 0, 0.1);
  --shadow-md: 4px 4px 0px rgba(0, 0, 0, 0.1);
  --shadow-lg: 6px 6px 0px rgba(0, 0, 0, 0.1);

  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-color: var(--border-medium);
}

body {
  font-family: 'Merriweather', serif;
  background-color: var(--bg-primary);
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stichTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding: var(--space-6);
  }
}

/* Header */
.header {
  text-align: center;
  margin-bottom: var(--space-6);
  padding: var(--space-6) 0;
  border-bottom: 4px double var(--ink-900);
  position: relative;
}

@media (min-width: 768px) {
  .header {
    margin-bottom: var(--space-8);
    padding: var(--space-8) 0;
  }
}

.header::before {
  content: "EXTRA! EXTRA!";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Courier Prime', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: var(--ink-600);
  background: var(--bg-primary);
  padding: 0 1rem;
}

.title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  color: var(--ink-900);
  text-transform: uppercase;
  letter-spacing: -0.05em;
  margin-bottom: var(--space-2);
  text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1);
}

.subtitle {
  font-family: 'Courier Prime', monospace;
  font-size: clamp(0.7rem, 2vw, 1rem);
  color: var(--ink-600);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-top: 1px solid var(--ink-900);
  border-bottom: 1px solid var(--ink-900);
  display: inline-block;
  padding: 0.5rem 1rem;
}

@media (min-width: 640px) {
  .subtitle {
    padding: 0.5rem 2rem;
  }
}

/* Card */
.card {
  background: var(--paper-50);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-8);
  position: relative;
}

.card-header {
  padding: var(--space-3);
  border-bottom: 2px solid var(--ink-900);
  background: var(--paper-200);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
}

@media (min-width: 640px) {
  .card-header {
    padding: var(--space-4) var(--space-6);
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.2rem, 4vw, 1.5rem);
  font-weight: 700;
  color: var(--ink-900);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  width: 100%;
}

@media (min-width: 640px) {
  .header-actions {
    width: auto;
    gap: var(--space-3);
  }
}

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

@media (min-width: 640px) {
  .card-content {
    padding: var(--space-6);
  }
}

/* Buttons */
.btn {
  padding: var(--space-3) var(--space-6);
  border: 2px solid var(--ink-900);
  border-radius: 0;
  font-family: 'Courier Prime', monospace;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 200ms ease;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0px var(--ink-900);
}

.btn:active {
  transform: translate(0, 0);
  box-shadow: none;
}

.btn-primary {
  background: var(--ink-900);
  color: var(--paper-100);
}

.btn-primary:hover {
  background: var(--ink-800);
}

.btn-secondary {
  background: transparent;
  color: var(--ink-900);
}

.btn-secondary:hover {
  background: var(--paper-200);
}

.btn-success {
  background: var(--paper-100);
  color: #2d5a27;
  border-color: #2d5a27;
}

.btn-success:hover {
  background: #2d5a27;
  color: var(--paper-100);
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Source Buttons */
.source-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .source-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
}

.source-buttons .btn {
  padding: var(--space-6);
  font-size: 1rem;
  flex-direction: column;
  justify-content: center;
  height: 150px;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23000000' fill-opacity='0.05' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E");
}

@media (min-width: 768px) {
  .source-buttons .btn {
    padding: var(--space-8);
    font-size: 1.2rem;
    height: 200px;
  }
}

.icon {
  width: 32px;
  height: 32px;
  margin-bottom: var(--space-2);
}

@media (min-width: 768px) {
  .icon {
    width: 48px;
    height: 48px;
  }
}

/* Source List */
.source-list {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  font-family: 'Courier Prime', monospace;
}

.source-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--paper-100);
  border: 1px solid var(--border-medium);
  transition: background 200ms ease;
}

.source-item:hover {
  background: var(--paper-200);
}

/* Content List */
.content-list {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--ink-900);
  padding: var(--space-2);
  background: var(--paper-200);
}

@media (min-width: 768px) {
  .content-list {
    gap: var(--space-4);
    max-height: 600px;
  }
}

.content-item {
  background: var(--paper-50);
  border: 1px solid var(--border-medium);
  padding: var(--space-4);
  transition: all 200ms ease;
  position: relative;
}

.content-item.selected {
  border: 2px solid var(--ink-900);
  background: var(--paper-100);
}

.content-item.selected::after {
  content: "SELECTED";
  position: absolute;
  top: -10px;
  right: 10px;
  background: var(--ink-900);
  color: var(--paper-100);
  font-size: 0.7rem;
  padding: 2px 6px;
  font-family: 'Courier Prime', monospace;
}

.content-item-header {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.content-item-header input[type="checkbox"] {
  margin-top: 4px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.content-item-body {
  flex: 1;
}

.content-item-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1rem, 3vw, 1.2rem);
  font-weight: 700;
  margin-bottom: var(--space-2);
  color: var(--ink-900);
  cursor: pointer;
  transition: color 200ms ease;
  word-wrap: break-word;
}

.content-item-title:hover {
  color: var(--ink-700);
  text-decoration: underline;
}

.content-item-preview {
  font-family: 'Merriweather', serif;
  font-size: clamp(0.8rem, 2vw, 0.9rem);
  line-height: 1.6;
  color: var(--ink-700);
  margin-top: var(--space-2);
  word-wrap: break-word;
}

.content-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: clamp(0.7rem, 1.5vw, 0.8rem);
  font-family: 'Courier Prime', monospace;
  color: var(--ink-600);
  margin-bottom: var(--space-3);
  border-bottom: 1px dashed var(--ink-300);
  padding-bottom: var(--space-2);
}

@media (min-width: 640px) {
  .content-item-meta {
    gap: var(--space-4);
  }
}

/* Progress */
.progress-container {
  margin-bottom: var(--space-6);
  border: 2px solid var(--ink-900);
  padding: var(--space-4);
  background: var(--paper-200);
}

.progress-bar {
  width: 100%;
  height: 20px;
  background: var(--paper-50);
  border: 1px solid var(--ink-900);
  margin-bottom: var(--space-3);
  position: relative;
}

.progress-fill {
  height: 100%;
  background: repeating-linear-gradient(45deg,
      var(--ink-900),
      var(--ink-900) 10px,
      var(--ink-700) 10px,
      var(--ink-700) 20px);
  transition: width 300ms ease;
  width: 0%;
}

.progress-text {
  text-align: center;
  font-family: 'Courier Prime', monospace;
  font-size: 0.9rem;
  color: var(--ink-900);
  text-transform: uppercase;
  animation: blink 1s infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* Results */
.results-list {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.result-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--paper-50);
  border: 1px solid var(--border-medium);
  font-family: 'Courier Prime', monospace;
  font-size: 0.9rem;
}

.result-item.success {
  border-left: 4px solid #2d5a27;
}

.result-item.error {
  border-left: 4px solid #8a1f1f;
}

.result-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.result-icon.success {
  color: #2d5a27;
}

.result-icon.error {
  color: #8a1f1f;
}

.result-text {
  flex: 1;
  word-break: break-all;
}

/* Footer */
.footer {
  text-align: center;
  padding: var(--space-8) 0;
  color: var(--ink-600);
  font-family: 'Courier Prime', monospace;
  font-size: 0.8rem;
  border-top: 1px solid var(--ink-300);
  margin-top: var(--space-12);
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--paper-50);
  border: 3px solid var(--ink-900);
  box-shadow: 8px 8px 0px rgba(0, 0, 0, 0.3);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1001;
}

.modal-header {
  padding: var(--space-4);
  border-bottom: 3px double var(--ink-900);
  background: var(--paper-200);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .modal-header {
    padding: var(--space-6);
    gap: var(--space-4);
  }
}

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 900;
  color: var(--ink-900);
  line-height: 1.2;
  flex: 1;
  word-wrap: break-word;
}

.modal-close {
  background: var(--ink-900);
  color: var(--paper-100);
  border: none;
  width: 40px;
  height: 40px;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: all 200ms ease;
  font-family: 'Courier Prime', monospace;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--ink-700);
  transform: rotate(90deg);
}

.modal-body {
  padding: var(--space-4);
}

@media (min-width: 640px) {
  .modal-body {
    padding: var(--space-6);
  }
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: 0.9rem;
  font-family: 'Courier Prime', monospace;
  color: var(--ink-600);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 2px dashed var(--ink-300);
}

.modal-text {
  font-family: 'Merriweather', serif;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink-900);
  margin-bottom: var(--space-6);
  text-align: justify;
  column-count: 1;
  column-gap: var(--space-6);
}

@media (min-width: 768px) {
  .modal-text {
    column-count: 2;
  }
}

.modal-media {
  margin-bottom: var(--space-6);
}

.modal-media h4 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink-900);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--ink-900);
  padding-bottom: var(--space-2);
}

.modal-media img {
  width: 100%;
  height: auto;
  border: 2px solid var(--ink-900);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-md);
}

.modal-media p {
  font-family: 'Courier Prime', monospace;
  font-size: 0.9rem;
  margin-bottom: var(--space-2);
}

.modal-media a {
  color: var(--ink-900);
  text-decoration: underline;
  word-break: break-all;
}

.modal-footer {
  padding: var(--space-4);
  border-top: 2px solid var(--ink-900);
  background: var(--paper-200);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

@media (min-width: 640px) {
  .modal-footer {
    padding: var(--space-6);
    flex-direction: row;
    gap: var(--space-3);
    justify-content: flex-end;
  }
}

/* Utilities */
.hidden {
  display: none;
}

/* Glitch Text for Modern Tech Feel */
.glitch-text {
  position: relative;
}

.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.8;
}

.glitch-text::before {
  left: 2px;
  text-shadow: -1px 0 #ff00ff;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

.glitch-text::after {
  left: -2px;
  text-shadow: -1px 0 #00f3ff;
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
  animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
  0% {
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    transform: translate(0);
  }

  20% {
    clip-path: polygon(0 5%, 100% 5%, 100% 25%, 0 25%);
    transform: translate(2px, -2px);
  }

  40% {
    clip-path: polygon(0 40%, 100% 40%, 100% 75%, 0 75%);
    transform: translate(1px, -1px);
  }

  60% {
    clip-path: polygon(0 10%, 100% 10%, 100% 95%, 0 95%);
    transform: translate(0);
  }

  100% {
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    transform: translate(0);
  }
}

@keyframes glitch-anim-2 {
  0% {
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    transform: translate(0);
  }

  20% {
    clip-path: polygon(0 50%, 100% 50%, 100% 80%, 0 80%);
    transform: translate(-2px, 2px);
  }

  40% {
    clip-path: polygon(0 60%, 100% 60%, 100% 85%, 0 85%);
    transform: translate(-1px, 1px);
  }

  100% {
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    transform: translate(0);
  }
}

/* Halloween Theme */
body.halloween {
  --paper-50: #1a0f0a;
  --paper-100: #2d1810;
  --paper-200: #3d2318;
  --paper-300: #4d2e20;
  --bg-primary: #1a0f0a;
  --bg-secondary: #2d1810;
  --bg-tertiary: #3d2318;
  --text-primary: #ff6b35;
  --text-secondary: #ffa07a;
  --text-inverse: #1a0f0a;
  --ink-900: #ff6b35;
  --ink-800: #ff8555;
  --ink-700: #ffa07a;
  --ink-600: #ffb89f;
  --border-medium: #ff6b35;
  --border-dark: #ff6b35;
}

body.halloween .card {
  background: #2d1810;
  border-color: #ff6b35;
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.3);
}

body.halloween .card-header {
  background: #3d2318;
  border-color: #ff6b35;
}

body.halloween .btn {
  border-color: #ff6b35;
}

body.halloween .btn-primary {
  background: #ff6b35;
  color: #1a0f0a;
}

body.halloween .btn-primary:hover {
  background: #ff8555;
  box-shadow: 4px 4px 0px #ff6b35;
}

body.halloween .content-item {
  background: #2d1810;
  border-color: #ff6b35;
}

body.halloween .content-item.selected {
  border-color: #ff6b35;
  background: #3d2318;
  box-shadow: 0 0 15px rgba(255, 107, 53, 0.4);
}

body.halloween .modal-content {
  background: #2d1810;
  border-color: #ff6b35;
  box-shadow: 0 0 30px rgba(255, 107, 53, 0.5);
}

body.halloween .modal-header {
  background: #3d2318;
  border-color: #ff6b35;
}

body.halloween .progress-bar {
  background: #3d2318;
  border-color: #ff6b35;
}

body.halloween .progress-fill {
  background: repeating-linear-gradient(45deg,
      #ff6b35,
      #ff6b35 10px,
      #ff8555 10px,
      #ff8555 20px);
}

/* Prevent horizontal overflow */
body {
  overflow-x: hidden;
}

.container {
  max-width: 100%;
  overflow-x: hidden;
}

/* Break long URLs and text */
.source-item label,
.content-item-preview,
.content-item-title,
.result-text,
.modal-text {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* Source list items */
.source-item label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Remove extra space at bottom */
.footer {
  margin-top: var(--space-8);
  margin-bottom: 0;
}

.main {
  margin-bottom: 0;
}

/* Mobile Responsive Fixes */
@media (max-width: 639px) {
  .title {
    font-size: 2rem !important;
  }
  
  .subtitle {
    font-size: 0.7rem !important;
    letter-spacing: 0.05em !important;
    padding: 0.5rem 1rem !important;
  }
  
  .card-title {
    font-size: 1.2rem !important;
  }
  
  .content-item-title {
    font-size: 1rem !important;
    word-break: break-word;
  }
  
  .content-item-meta {
    flex-wrap: wrap;
    gap: var(--space-2) !important;
    font-size: 0.7rem !important;
  }
  
  .content-item-meta span {
    word-break: break-all;
  }
  
  .header-actions {
    flex-wrap: wrap;
  }
  
  .btn {
    font-size: 0.9rem;
    padding: var(--space-2) var(--space-4);
  }
  
  .modal-title {
    font-size: 1.5rem !important;
  }
  
  .source-buttons .btn {
    height: 120px;
    font-size: 0.9rem;
  }
  
  .container {
    padding: var(--space-2);
  }
  
  .card-content {
    padding: var(--space-4);
  }
}
