@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --ink-black: #0a0a0a;
  --paper-white: #fafaf8;
  --press-red: #d72638;
  --ink-gray: #2a2a2a;
  --newsprint-gray: #6a6a6a;
  --border-gray: #c8c8c8;
  --accent-gold: #c9a961;
}

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

body {
  font-family: 'Libre Baskerville', Georgia, serif;
  background: var(--paper-white);
  color: var(--ink-black);
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

/* Paper texture overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,.01) 2px, rgba(0,0,0,.01) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0,0,0,.01) 2px, rgba(0,0,0,.01) 4px);
  pointer-events: none;
  z-index: 1;
  opacity: 0.4;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0;
  position: relative;
  z-index: 2;
  background: var(--paper-white);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.08);
}

/* Newspaper Masthead Header */
.header {
  border-bottom: 6px solid var(--ink-black);
  padding: 60px 80px 40px;
  background: var(--paper-white);
  position: relative;
}

.header::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--press-red);
}

.logo {
  display: none;
}

.header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 0.9;
  text-transform: uppercase;
  color: var(--ink-black);
  margin-bottom: 20px;
  text-align: center;
  position: relative;
}

.header h1::before {
  content: '◆';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -30px;
  font-size: 1rem;
  color: var(--press-red);
}

.subtitle {
  text-align: center;
  font-size: 1rem;
  font-style: italic;
  color: var(--newsprint-gray);
  margin-bottom: 30px;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.supported-formats {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--border-gray);
}

.format-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 14px;
  border: 1px solid var(--ink-black);
  background: white;
  color: var(--ink-black);
  transition: all 0.2s;
}

.format-badge:hover {
  background: var(--ink-black);
  color: white;
  transform: translateY(-2px);
}

/* Main Content */
.main-content {
  padding: 60px 80px;
}

/* Upload Section */
.upload-section {
  background: white;
  border: 3px solid var(--ink-black);
  padding: 60px;
  position: relative;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.1);
  margin-bottom: 40px;
}

.upload-section::before {
  content: 'SUBMIT DOCUMENTS';
  position: absolute;
  top: -14px;
  left: 40px;
  background: var(--paper-white);
  padding: 0 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--ink-black);
}

.upload-area {
  border: 2px dashed var(--border-gray);
  padding: 80px 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: linear-gradient(180deg, transparent 0%, rgba(215, 38, 56, 0.02) 100%);
}

.upload-area:hover {
  border-color: var(--ink-black);
  background: rgba(215, 38, 56, 0.03);
}

.upload-area.drag-over {
  border-color: var(--press-red);
  background: rgba(215, 38, 56, 0.05);
}

.upload-content {
  position: relative;
}

.upload-icon {
  color: var(--press-red);
  margin-bottom: 30px;
  display: inline-block;
}

.upload-area h3 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  margin-bottom: 15px;
  color: var(--ink-black);
  font-weight: 700;
}

.upload-area p {
  color: var(--newsprint-gray);
  font-size: 1rem;
  margin-bottom: 30px;
  font-style: italic;
}

.btn-browse {
  font-family: 'IBM Plex Mono', monospace;
  padding: 16px 40px;
  background: var(--ink-black);
  color: white;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  position: relative;
  overflow: hidden;
}

.btn-browse::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--press-red);
  transition: left 0.3s;
}

.btn-browse:hover::before {
  left: 0;
}

.btn-browse:hover {
  color: white;
}

.btn-browse span {
  position: relative;
  z-index: 1;
}

/* File List */
.file-list {
  margin-top: 40px;
  display: grid;
  gap: 15px;
  min-height: 100px;
}

.file-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: white;
  border: 2px solid var(--border-gray);
  transition: all 0.2s;
}

.file-item:hover {
  border-color: var(--ink-black);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.05);
}

.file-item svg {
  flex-shrink: 0;
  color: var(--press-red);
}

.file-item span {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  font-weight: 500;
}

.file-size {
  color: var(--newsprint-gray);
  font-size: 0.8rem !important;
}

.btn-remove {
  font-family: 'IBM Plex Mono', monospace;
  padding: 8px 16px;
  background: white;
  border: 1px solid var(--ink-black);
  color: var(--ink-black);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-remove:hover {
  background: var(--ink-black);
  color: white;
}

/* Add More Files Button */
.add-more-files {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  background: white;
  border: 2px dashed var(--border-gray);
  transition: all 0.2s;
  cursor: pointer;
  color: var(--newsprint-gray);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.add-more-files:hover {
  border-color: var(--ink-black);
  border-style: solid;
  background: rgba(0, 0, 0, 0.02);
  color: var(--ink-black);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.05);
}

.add-more-files svg {
  color: var(--press-red);
  transition: transform 0.2s;
}

.add-more-files:hover svg {
  transform: rotate(90deg);
}

/* Turnstile */
.turnstile-container {
  display: flex;
  justify-content: center;
  margin: 40px 0;
  padding: 30px;
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid var(--border-gray);
  border-bottom: 1px solid var(--border-gray);
}

/* Convert Button */
.btn-convert {
  width: 100%;
  padding: 24px;
  background: var(--press-red);
  color: white;
  border: 3px solid var(--ink-black);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.15);
  position: relative;
}

.btn-convert:hover:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.15);
}

.btn-convert:active:not(:disabled) {
  transform: translate(4px, 4px);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

.btn-convert:disabled {
  background: var(--border-gray);
  color: var(--newsprint-gray);
  cursor: not-allowed;
  border-color: var(--border-gray);
  box-shadow: none;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 60px;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--border-gray);
  border-top: 4px solid var(--press-red);
  border-radius: 50%;
  margin: 0 auto 25px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-state p {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--ink-black);
}

.loading-subtext {
  font-size: 0.95rem;
  color: var(--newsprint-gray);
  font-style: italic;
}

/* Results Section */
.results-section {
  background: white;
  border: 3px solid var(--ink-black);
  padding: 50px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.1);
  position: relative;
}

.results-section::before {
  content: 'CONVERTED DOCUMENT';
  position: absolute;
  top: -14px;
  left: 40px;
  background: var(--paper-white);
  padding: 0 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--ink-black);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  padding-bottom: 30px;
  border-bottom: 2px solid var(--ink-black);
  flex-wrap: wrap;
  gap: 20px;
}

.results-title {
  display: flex;
  align-items: center;
  gap: 15px;
}

.results-title svg {
  color: var(--press-red);
}

.results-title h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink-black);
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-action {
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: white;
  border: 2px solid var(--ink-black);
  color: var(--ink-black);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-action:hover {
  background: var(--ink-black);
  color: white;
  transform: translateY(-2px);
}

.btn-action.active {
  background: var(--ink-black);
  color: white;
}

.btn-action.btn-primary {
  background: var(--press-red);
  border-color: var(--press-red);
  color: white;
}

.btn-action.btn-primary:hover {
  background: #b81e2f;
  border-color: #b81e2f;
}

/* Preview Container */
.preview-container {
  background: white;
  border: 2px solid var(--border-gray);
  padding: 50px;
  min-height: 600px;
  max-height: calc(100vh - 400px);
  overflow-y: auto;
}

.preview-container::-webkit-scrollbar {
  width: 12px;
}

.preview-container::-webkit-scrollbar-track {
  background: var(--paper-white);
  border-left: 1px solid var(--border-gray);
}

.preview-container::-webkit-scrollbar-thumb {
  background: var(--ink-black);
  border: 2px solid var(--paper-white);
}

.preview-container::-webkit-scrollbar-thumb:hover {
  background: var(--press-red);
}

/* Markdown Preview - Editorial Style */
.markdown-preview {
  font-family: 'Libre Baskerville', Georgia, serif;
  line-height: 1.8;
  color: var(--ink-black);
  max-width: 800px;
  margin: 0 auto;
}

.markdown-preview h1 {
  font-family: 'Playfair Display', serif;
  font-size: 3rem;
  font-weight: 900;
  margin: 2rem 0 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 4px solid var(--ink-black);
  color: var(--ink-black);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.markdown-preview h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  margin: 1.8rem 0 1rem;
  color: var(--ink-black);
  line-height: 1.2;
  position: relative;
  padding-left: 20px;
}

.markdown-preview h2::before {
  content: '■';
  position: absolute;
  left: 0;
  color: var(--press-red);
  font-size: 0.7em;
}

.markdown-preview h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 1.5rem 0 0.8rem;
  color: var(--ink-gray);
}

.markdown-preview h4 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 1.2rem 0 0.6rem;
  color: var(--ink-gray);
  font-style: italic;
}

.markdown-preview p {
  margin: 1.2rem 0;
  font-size: 1.05rem;
  color: var(--ink-black);
  text-align: justify;
}

.markdown-preview p:first-letter {
  font-size: 1.2em;
  font-weight: 700;
}

.markdown-preview ul,
.markdown-preview ol {
  margin: 1.2rem 0;
  padding-left: 2.5rem;
}

.markdown-preview li {
  margin: 0.8rem 0;
  font-size: 1rem;
  line-height: 1.7;
}

.markdown-preview a {
  color: var(--press-red);
  text-decoration: none;
  border-bottom: 2px solid var(--press-red);
  transition: all 0.2s;
  font-weight: 600;
}

.markdown-preview a:hover {
  color: var(--ink-black);
  border-bottom-color: var(--ink-black);
}

.markdown-preview code {
  font-family: 'IBM Plex Mono', monospace;
  background: var(--ink-black);
  color: white;
  padding: 3px 8px;
  font-size: 0.85em;
  border: 1px solid var(--ink-black);
}

.markdown-preview pre {
  background: var(--ink-black);
  border: 3px solid var(--ink-black);
  padding: 25px;
  overflow-x: auto;
  margin: 2rem 0;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.1);
}

.markdown-preview pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: #f8f8f2;
  font-size: 0.9rem;
  line-height: 1.6;
}

.markdown-preview blockquote {
  border-left: 6px solid var(--press-red);
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  background: rgba(215, 38, 56, 0.03);
  color: var(--ink-gray);
  font-style: italic;
  font-size: 1.1rem;
  position: relative;
}

.markdown-preview blockquote::before {
  content: '"';
  font-family: 'Playfair Display', serif;
  font-size: 4rem;
  position: absolute;
  left: 10px;
  top: -10px;
  color: var(--press-red);
  opacity: 0.3;
}

.markdown-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95rem;
  border: 2px solid var(--ink-black);
}

.markdown-preview th,
.markdown-preview td {
  padding: 14px 18px;
  border: 1px solid var(--border-gray);
  text-align: left;
}

.markdown-preview th {
  background: var(--ink-black);
  color: white;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
}

.markdown-preview tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
  margin: 2rem 0;
  border: 3px solid var(--ink-black);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.1);
}

.markdown-preview hr {
  border: none;
  border-top: 2px solid var(--ink-black);
  margin: 3rem 0;
  position: relative;
}

.markdown-preview hr::after {
  content: '◆';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper-white);
  padding: 0 15px;
  color: var(--press-red);
}

/* Raw Markdown View */
.markdown-raw {
  font-family: 'IBM Plex Mono', monospace;
  background: var(--ink-black);
  color: #f8f8f2;
  padding: 30px;
  font-size: 0.9rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Footer */
.footer {
  text-align: center;
  padding: 40px;
  border-top: 2px solid var(--ink-black);
  background: var(--paper-white);
  font-size: 0.9rem;
  color: var(--newsprint-gray);
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.05em;
}

.footer strong {
  color: var(--ink-black);
  font-weight: 600;
}

/* Error State */
.error-message {
  background: rgba(215, 38, 56, 0.05);
  border: 2px solid var(--press-red);
  color: var(--ink-black);
  padding: 25px;
  margin-top: 20px;
  display: flex;
  align-items: flex-start;
  gap: 15px;
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.6;
}

.error-message svg {
  color: var(--press-red);
  flex-shrink: 0;
  margin-top: 2px;
}

.error-message strong {
  color: var(--press-red);
  display: block;
  margin-bottom: 10px;
  font-size: 1.1em;
}

.error-message p {
  margin: 8px 0;
  color: var(--ink-gray);
  font-size: 0.9rem;
}

.error-message a {
  color: var(--ink-black);
  text-decoration: none;
  border-bottom: 2px solid var(--ink-black);
  font-weight: 600;
  transition: all 0.2s;
}

.error-message a:hover {
  color: var(--press-red);
  border-bottom-color: var(--press-red);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .header h1 {
    font-size: 3.5rem;
  }

  .preview-container {
    padding: 30px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0;
  }

  .header {
    padding: 40px 30px 30px;
  }

  .header h1 {
    font-size: 2.5rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .main-content {
    padding: 40px 30px;
  }

  .upload-section {
    padding: 40px 30px;
  }

  .upload-area {
    padding: 50px 20px;
  }

  .results-section {
    padding: 30px 20px;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .action-buttons {
    width: 100%;
  }

  .btn-action {
    flex: 1;
    justify-content: center;
    font-size: 0.75rem;
  }

  .preview-container {
    padding: 25px;
    max-height: 500px;
  }

  .markdown-preview h1 {
    font-size: 2rem;
  }

  .markdown-preview h2 {
    font-size: 1.5rem;
  }

  .markdown-preview p {
    text-align: left;
  }
}

/* Print-style animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.upload-section,
.results-section {
  animation: fadeIn 0.6s ease-out;
}

.format-badge {
  animation: fadeIn 0.4s ease-out backwards;
}

.format-badge:nth-child(1) { animation-delay: 0.1s; }
.format-badge:nth-child(2) { animation-delay: 0.15s; }
.format-badge:nth-child(3) { animation-delay: 0.2s; }
.format-badge:nth-child(4) { animation-delay: 0.25s; }
.format-badge:nth-child(5) { animation-delay: 0.3s; }
.format-badge:nth-child(6) { animation-delay: 0.35s; }

/* Format Notice */
.format-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 25px;
  padding: 16px 30px;
  background: rgba(201, 169, 97, 0.08);
  border: 1px solid var(--accent-gold);
  border-radius: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: var(--ink-gray);
  line-height: 1.5;
  animation: fadeIn 0.6s ease-out 0.5s backwards;
}

.format-notice svg {
  color: var(--accent-gold);
  flex-shrink: 0;
}

.format-notice a {
  color: var(--ink-black);
  text-decoration: none;
  border-bottom: 2px solid var(--ink-black);
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}

.format-notice a:hover {
  color: var(--press-red);
  border-bottom-color: var(--press-red);
}
