/* ============================================================
   RISC OS File Converter — stylesheet
   Colour palette: warm cream bg, Acorn navy/teal accents
   ============================================================ */

/* ---------- Reset / base ---------- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  background-color: #f5f0e8;
  color: #1a1a2e;
  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: #1a6b72;
  text-decoration: underline;
}

a:hover {
  color: #0d4a50;
}

/* ---------- Header — pinstripe ---------- */

header {
  background-color: #1a2b4a;
  /* Classic Acorn pinstripe: fine diagonal lines over the navy base */
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.04) 3px,
      rgba(255, 255, 255, 0.04) 4px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.03) 3px,
      rgba(255, 255, 255, 0.03) 4px
    );
  color: #ffffff;
  padding: 0;
  border-bottom: 3px solid #c8860a;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 24px 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

.logo-text {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 1.6rem;
  font-weight: normal;
  letter-spacing: 0.03em;
  color: #f0e8d0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.subtitle {
  margin-top: 4px;
  font-size: 0.875rem;
  color: #a8bcd0;
  letter-spacing: 0.02em;
}

/* ---------- Main / layout ---------- */

main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---------- State visibility ---------- */

main section {
  display: none;
}

main section.active {
  display: block;
}

/* ---------- Drop zone ---------- */

#drop-zone {
  border: 2px dashed #7a9ab8;
  border-radius: 8px;
  background: #ffffff;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  margin-bottom: 40px;
}

#drop-zone:hover {
  border-color: #1a6b72;
  background: #f0f8f8;
  box-shadow: 0 2px 12px rgba(26, 107, 114, 0.15);
}

#drop-zone.drag-over {
  border-color: #1a6b72;
  border-style: solid;
  background: #e6f4f5;
  box-shadow: 0 0 0 4px rgba(26, 107, 114, 0.18);
}

.drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 24px;
  text-align: center;
}

.drop-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  line-height: 1;
}

.drop-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #1a2b4a;
  margin-bottom: 6px;
}

.drop-sub {
  font-size: 0.95rem;
  color: #5a6a7e;
  margin-bottom: 14px;
}

.drop-hint {
  font-size: 0.8rem;
  color: #8a9aae;
  letter-spacing: 0.03em;
}

/* ---------- Link-style button (inline) ---------- */

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #1a6b72;
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
  font-family: inherit;
}

.link-btn:hover {
  color: #0d4a50;
}

/* ---------- Supported types grid ---------- */

#supported-types h3 {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5a6a7e;
  margin-bottom: 14px;
}

#type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.type-card {
  background: #ffffff;
  border: 1px solid #d4cfc6;
  border-left: 3px solid #1a6b72;
  border-radius: 4px;
  padding: 10px 12px;
  transition: box-shadow 0.15s;
}

.type-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.type-card-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a2b4a;
  margin-bottom: 2px;
}

.type-card-ext {
  font-size: 0.75rem;
  color: #1a6b72;
  font-family: "Courier New", Courier, monospace;
  margin-bottom: 4px;
}

.type-card-desc {
  font-size: 0.78rem;
  color: #6a7a8e;
  line-height: 1.4;
}

/* ---------- Processing state ---------- */

#state-processing {
  min-height: 300px;
  display: flex !important; /* override section:not(.active) when active */
  align-items: center;
  justify-content: center;
}

#state-processing.active {
  display: flex;
}

.processing-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 48px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #d4cfc6;
  min-width: 280px;
  text-align: center;
}

/* Spinner */
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #d4cfc6;
  border-top-color: #1a6b72;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#proc-status {
  font-size: 1rem;
  color: #3a4a5e;
}

.proc-detected {
  font-size: 1rem;
  font-weight: 700;
  color: #1a6b72;
  min-height: 1.5em;
}

/* ---------- Results state ---------- */

.results-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  margin-bottom: 32px;
}

.results-left {
  flex: 1 1 55%;
  min-width: 0;
}

.results-right {
  flex: 1 1 42%;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Preview panel */
#preview-panel {
  background: #2a2a2a;
  border-radius: 6px;
  border: 1px solid #555;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  max-height: 500px;
  overflow: hidden;
  position: relative;
}

#preview-panel img {
  max-width: 100%;
  max-height: 500px;
  display: block;
  image-rendering: pixelated; /* for low-res RISC OS sprites */
}

#preview-panel svg {
  max-width: 100%;
  max-height: 500px;
}

#preview-panel pre {
  color: #d4e8d4;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.78rem;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-all;
  text-align: left;
  overflow-y: auto;
  max-height: 500px;
  width: 100%;
  align-self: stretch;
}

#preview-panel iframe {
  width: 100%;
  height: 460px;
  border: none;
  background: #fff;
}

.preview-placeholder {
  color: #777;
  font-size: 0.9rem;
  font-style: italic;
}

/* File metadata */
#file-meta {
  background: #ffffff;
  border: 1px solid #d4cfc6;
  border-radius: 6px;
  padding: 16px 18px;
}

#file-meta h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #8a9aae;
  margin-bottom: 12px;
}

.meta-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 0.875rem;
}

.meta-label {
  color: #7a8a9e;
  font-size: 0.78rem;
  white-space: nowrap;
  min-width: 90px;
}

.meta-value {
  color: #1a2b4a;
  font-weight: 500;
  word-break: break-all;
}

.meta-value.mono {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.82rem;
  color: #2a5a62;
}

.meta-notes {
  font-size: 0.8rem;
  color: #6a7a8e;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #eae6e0;
  line-height: 1.5;
}

/* Download buttons */
#download-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#download-list h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #8a9aae;
  margin-bottom: 4px;
}

/* ---------- Buttons ---------- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #1a4a6a;
  color: #ffffff;
  border: none;
  border-radius: 5px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  background: #0d3350;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  color: #ffffff;
  text-decoration: none;
}

.btn-primary:active {
  background: #091e30;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: transparent;
  color: #1a4a6a;
  border: 2px solid #1a4a6a;
  border-radius: 5px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.btn-secondary:hover {
  background: #1a4a6a;
  color: #ffffff;
}

.btn-secondary:active {
  background: #0d3350;
  color: #ffffff;
}

.btn-download {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  color: #1a2b4a;
  border: 1px solid #b0c4d4;
  border-left: 3px solid #1a6b72;
  border-radius: 5px;
  padding: 10px 14px;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, box-shadow 0.15s;
  width: 100%;
  text-align: left;
}

.btn-download:hover {
  background: #e8f4f5;
  box-shadow: 0 1px 6px rgba(26, 107, 114, 0.15);
  text-decoration: none;
  color: #1a2b4a;
}

.btn-download-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.btn-download-label {
  flex: 1;
  font-weight: 600;
}

.btn-download-sub {
  font-size: 0.75rem;
  color: #6a7a8e;
  white-space: nowrap;
}

/* ---------- Archive panel ---------- */

#archive-panel {
  margin-top: 8px;
}

#archive-panel h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1a2b4a;
  margin-bottom: 14px;
}

#archive-list {
  overflow-x: auto;
  margin-bottom: 18px;
  border-radius: 6px;
  border: 1px solid #d4cfc6;
}

#archive-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#archive-list thead th {
  background: #2a3d5a;
  color: #c8d8e8;
  padding: 9px 12px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

#archive-list tbody tr:nth-child(odd) {
  background: #ffffff;
}

#archive-list tbody tr:nth-child(even) {
  background: #f0ece4;
}

#archive-list tbody tr:hover {
  background: #e8f0f8;
}

#archive-list tbody td {
  padding: 7px 12px;
  color: #1a2b4a;
  border-bottom: 1px solid #e0dcd4;
  vertical-align: middle;
}

#archive-list tbody td.filename {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.82rem;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#archive-list tbody td.filetype {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.8rem;
  color: #2a5a62;
}

#archive-list tbody td.filesize {
  text-align: right;
  font-size: 0.82rem;
  color: #5a6a7e;
  white-space: nowrap;
}

.archive-convertible {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.archive-convertible.yes {
  background: #d4eeda;
  color: #1a5a2a;
}

.archive-convertible.no {
  background: #e8e4da;
  color: #6a5a4a;
}

.archive-more-note {
  font-size: 0.82rem;
  color: #7a8a9e;
  font-style: italic;
  padding: 8px 12px;
  background: #f5f0e8;
}

.archive-actions {
  margin-top: 14px;
}

/* ---------- Unrecognised state ---------- */

.unrec-box,
.unsup-box {
  background: #ffffff;
  border: 1px solid #d4cfc6;
  border-left: 4px solid #c8860a;
  border-radius: 6px;
  padding: 28px 32px;
  max-width: 680px;
}

.unrec-box h2,
.unsup-box h2 {
  font-size: 1.2rem;
  color: #8a4a0a;
  margin-bottom: 12px;
}

.unrec-box p,
.unsup-box p {
  color: #3a4a5e;
  margin-bottom: 18px;
  font-size: 0.95rem;
}

#unrec-actions {
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Hex dump */
.hex-dump {
  background: #1e2030;
  color: #c8d8a8;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.78rem;
  padding: 16px;
  border-radius: 4px;
  word-break: break-all;
  line-height: 1.7;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 20px;
  white-space: pre;
}

.hex-dump .hex-offset {
  color: #6878a8;
  user-select: none;
}

.hex-dump .hex-bytes {
  color: #c8d8a8;
}

.hex-dump .hex-ascii {
  color: #a8c8a8;
  margin-left: 10px;
}

/* ---------- Footer ---------- */

footer {
  background: #1a2b4a;
  background-image:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.03) 3px,
      rgba(255, 255, 255, 0.03) 4px
    );
  color: #7a9ab8;
  text-align: center;
  padding: 14px 24px;
  font-size: 0.82rem;
  border-top: 2px solid #c8860a;
  margin-top: auto;
}

footer a {
  color: #8ab8d0;
}

footer a:hover {
  color: #b0d4e8;
}

/* ---------- Utility ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .logo-text {
    font-size: 1.15rem;
  }

  .header-inner {
    padding: 14px 16px 12px;
  }

  main {
    padding: 20px 14px;
  }

  .drop-inner {
    padding: 36px 16px;
  }

  .drop-title {
    font-size: 1rem;
  }

  .results-layout {
    flex-direction: column;
  }

  .results-left,
  .results-right {
    flex: none;
    width: 100%;
    min-width: 0;
  }

  #type-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .unrec-box,
  .unsup-box {
    padding: 20px 18px;
  }

  .processing-box {
    min-width: 0;
    padding: 32px 24px;
  }
}

@media (max-width: 400px) {
  #type-grid {
    grid-template-columns: 1fr 1fr;
  }

  .logo-text {
    font-size: 1rem;
  }
}
