/* ============================================================
   ebook-freedom — style.css
   Clean, minimal design with dark mode support.
   ============================================================ */

:root {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #666666;
  --accent: #0066cc;
  --accent-hover: #0052a3;
  --accent-text: #ffffff;
  --success: #2d7a2d;
  --success-bg: #eaf4ea;
  --error: #cc2200;
  --error-bg: #fdf0ed;
  --warning: #b36200;
  --warning-bg: #fdf6e3;
  --info: #005599;
  --info-bg: #e8f0fb;
  --progress-bg: #e0e0e0;
  --progress-fill: #0066cc;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --transition: 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --surface: #2a2a2a;
    --border: #404040;
    --text: #f0f0f0;
    --text-muted: #999999;
    --accent: #4d9fff;
    --accent-hover: #6db3ff;
    --accent-text: #0a0a0a;
    --success: #5cb85c;
    --success-bg: #1a2e1a;
    --error: #ff6b4a;
    --error-bg: #2e1a18;
    --warning: #ffb347;
    --warning-bg: #2e2210;
    --info: #4d9fff;
    --info-bg: #0e1e30;
    --progress-bg: #404040;
    --progress-fill: #4d9fff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  }
}

/* ─────────────────── Reset & Base ─────────────────── */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ─────────────────── Layout ─────────────────── */

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ─────────────────── Header ─────────────────── */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0 1rem;
  margin-bottom: 2rem;
}

.site-header .container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
}

/* ─────────────────── Main ─────────────────── */

main {
  flex: 1;
  padding-bottom: 2rem;
}

/* ─────────────────── Drop Zone ─────────────────── */

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface);
  outline: none;
}

.drop-zone:hover,
.drop-zone:focus {
  border-color: var(--accent);
  background: var(--info-bg);
}

.drop-zone.drag-active {
  border-color: var(--accent);
  background: var(--info-bg);
  border-style: solid;
}

.drop-zone__icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
  user-select: none;
}

.drop-zone__title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.375rem;
  color: var(--text);
}

.drop-zone__sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.drop-zone__formats {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.format-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: monospace;
  color: var(--text-muted);
}

/* ─────────────────── File Info ─────────────────── */

.file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-top: 1rem;
}

.file-info__icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.file-info__name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.file-info__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

.file-info__dismiss {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0.25rem;
  border-radius: 4px;
  line-height: 1;
}
.file-info__dismiss:hover {
  color: var(--error);
  background: var(--error-bg);
}

/* ─────────────────── Key Input Section ─────────────────── */

.key-input-section {
  margin-top: 1.5rem;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.25s ease;
}

.key-input-section.visible {
  max-height: 400px;
  opacity: 1;
}

.key-input-section__inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.key-input-section__title {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.key-input-section__hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}
.key-input-section__hint a {
  font-size: inherit;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.form-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.625rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: monospace;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.form-input-file {
  font-family: inherit;
  padding: 0.5rem 0.75rem;
}

/* ─────────────────── Buttons ─────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  opacity: 0.9;
}

.decrypt-btn {
  margin-top: 1rem;
  width: 100%;
}

/* ─────────────────── Progress ─────────────────── */

.progress-section {
  margin-top: 1.5rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.progress-bar {
  height: 8px;
  background: var(--progress-bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

/* ─────────────────── Status Messages ─────────────────── */

.status-message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
  display: none;
}

.status-message.visible {
  display: block;
}

.status-info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid color-mix(in srgb, var(--info) 30%, transparent);
}

.status-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
}

.status-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid color-mix(in srgb, var(--error) 30%, transparent);
}

.status-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
}

/* ─────────────────── Download Section ─────────────────── */

.download-section {
  margin-top: 1.5rem;
  display: none;
}

.download-section.visible {
  display: block;
}

.download-card {
  background: var(--success-bg);
  border: 1px solid color-mix(in srgb, var(--success) 40%, transparent);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.download-card__icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.download-card__info {
  flex: 1;
  min-width: 0;
}

.download-card__title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--success);
  margin: 0 0 0.25rem;
}

.download-card__sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─────────────────── How-to Panel ─────────────────── */

.howto-panel {
  margin-top: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.howto-panel summary {
  cursor: pointer;
  padding: 0.875rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.howto-panel summary::-webkit-details-marker { display: none; }
.howto-panel summary::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform var(--transition);
}
.howto-panel[open] summary::before {
  transform: rotate(90deg);
}

.howto-panel__body {
  padding: 0 1rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.howto-panel__body h3 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  margin: 1rem 0 0.375rem;
}

.howto-panel__body ul {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.howto-panel__body li {
  margin-bottom: 0.25rem;
}

/* ─────────────────── Footer ─────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--text-muted);
}

.disclaimer {
  margin-top: 1.5rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border-left: 3px solid var(--warning);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─────────────────── Responsive ─────────────────── */

@media (max-width: 480px) {
  .drop-zone {
    padding: 2rem 1rem;
  }

  .download-card {
    flex-direction: column;
    text-align: center;
  }

  .site-footer .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-title {
    font-size: 1.375rem;
  }
}

/* ─────────────────── Utility ─────────────────── */

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ─────────────────── Saved key row ─────────────────── */

.saved-key-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.375rem;
  font-size: 0.85rem;
}

.saved-badge {
  color: var(--success);
  font-weight: 500;
}

.forget-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.forget-btn:hover {
  color: var(--error);
}

.form-hint {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─────────────────── Cover thumbnail ─────────────────── */

.file-info__cover {
  width: 48px;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--border);
}

/* Hide the emoji icon when cover is shown */
.file-info:has(.file-info__cover:not([hidden])) .file-info__icon {
  display: none;
}

/* ─────────────────── Format badge (file card) ─────────────────── */

.file-info__meta-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.125rem;
}

.file-format-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* Kindle — warm amber */
.file-format-badge.format-kindle {
  background: #fff3cd;
  color: #7a5000;
  border: 1px solid #f0c040;
}
/* Adobe ADEPT — cool blue */
.file-format-badge.format-adobe_epub,
.file-format-badge.format-adobe_pdf {
  background: #dce8ff;
  color: #003070;
  border: 1px solid #7aaaf0;
}
/* Kobo — soft teal */
.file-format-badge.format-kobo_epub {
  background: #d4f4f0;
  color: #00504a;
  border: 1px solid #50cfc0;
}

@media (prefers-color-scheme: dark) {
  .file-format-badge.format-kindle       { background: #3a2800; color: #ffd070; border-color: #7a5000; }
  .file-format-badge.format-adobe_epub,
  .file-format-badge.format-adobe_pdf   { background: #0a1e3a; color: #80b0ff; border-color: #003070; }
  .file-format-badge.format-kobo_epub   { background: #003830; color: #70e0d0; border-color: #00504a; }
}

/* ─────────────────── Form label row (label + Paste btn) ─────────────────── */

.form-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.paste-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}

.paste-btn:hover {
  background: var(--info-bg);
  border-color: var(--accent);
}

/* ─────────────────── Validation hints ─────────────────── */

.validation-hint {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  min-height: 1.1em;
  transition: color 0.15s ease;
}

.hint-ok   { color: var(--success); }
.hint-warn { color: var(--warning); }

/* ─────────────────── Increase animation max-height for longer Adobe hint ─────────────────── */

.key-input-section.visible {
  max-height: 700px;
}
