/* mobile.css — global overrides for EPUB HTMLs with Auto-Theme Detection */

/* 1. DEFINE VARIABLES (Default to Light Mode) */
:root {
  --bg-color: #ffffff;
  --text-color: #111111;
  --link-color: #007aff;
  --meta-color: #555555;
  --caption-color: #444444;
  --border-color: #dddddd;
  --input-bg: #f0f0f0;
  --input-text: #111111;
  --input-placeholder: #777777;
  --results-bg: #f9f9f9;
}

/* 2. DARK MODE OVERRIDES (System Auto-Detect) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #111111;
    --text-color: #eeeeee;
    --link-color: #62a3ff;
    --meta-color: #c8c8c8;
    --caption-color: #d8d8d8;
    --border-color: #444444;
    --input-bg: #222222;
    --input-text: #ffffff;
    --input-placeholder: #bbbbbb;
    --results-bg: #1a1a1a;
  }

  /* Dim images slightly in dark mode */
  img, video, iframe {
    opacity: 0.9;
  }

  /* Force common hard-coded dark/gray EPUB text colors to remain readable. */
  [style*="color:#000"],
  [style*="color: #000"],
  [style*="color:#111"],
  [style*="color: #111"],
  [style*="color:#222"],
  [style*="color: #222"],
  [style*="color:#333"],
  [style*="color: #333"],
  [style*="color:#444"],
  [style*="color: #444"],
  [style*="color:#555"],
  [style*="color: #555"],
  [style*="color:black"],
  [style*="color: black"],
  [style*="color:gray"],
  [style*="color: gray"],
  [style*="color:grey"],
  [style*="color: grey"],
  [style*="color:rgb(0,0,0)"],
  [style*="color: rgb(0,0,0)"],
  [style*="color:rgb(34,34,34)"],
  [style*="color: rgb(34,34,34)"],
  [style*="color:rgb(51,51,51)"],
  [style*="color: rgb(51,51,51)"],
  [style*="color:rgb(85,85,85)"],
  [style*="color: rgb(85,85,85)"] {
    color: var(--text-color) !important;
  }

  blockquote,
  blockquote *,
  [class*="blockquote"],
  [class*="blockquote"] *,
  [class*="note"],
  [class*="note"] *,
  .calibre18,
  .calibre18 *,
  .calibre19,
  .calibre19 *,
  .news-figure-credit,
  .news-figure-credit * {
    color: var(--text-color) !important;
  }
}

/* 3. APPLY VARIABLES & GLOBAL STYLES */
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 22px;
  line-height: 1.7;
  margin: 0 auto;
  padding: 1rem;
  max-width: 700px;
  
  /* Use Variables Here */
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
}

body, p, div, span, li, dt, dd, blockquote, td, th, em, strong {
  color: inherit;
}

/* --- MOBILE OVERRIDES (Phones only) --- */
@media screen and (max-width: 768px) {
  html, body {
    font-size: 22px; /* Your preferred large text for phones */
    padding: 15px;   /* Slightly less padding on small screens */
  }
}

/* Make images responsive */
img, video, iframe {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin: 1rem auto;
}

/* Prevent tiny captions or footnotes */
small, figcaption,
[class*="caption"], [class*="Caption"],
[class*="description"], [class*="Description"] {
  font-size: 0.9em;
  color: var(--caption-color);
}

figcaption *, small *,
[class*="caption"] *, [class*="Caption"] *,
[class*="description"] *, [class*="Description"] * {
  color: inherit !important;
}

/* Links and Headings */
a {
  color: var(--link-color);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
  margin-top: 1.2em;
  color: var(--text-color); /* Matches body text color now */
}

/* Search input */
#q {
    width: 60%;
    padding: 6px;
    background-color: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    caret-color: var(--link-color);
}

#q::placeholder {
    color: var(--input-placeholder);
}

/* Results container */
#results {
    background-color: var(--results-bg);
    color: var(--text-color);
    padding: 1em;
    border-radius: 4px; /* Optional polish */
}

#results a {
    color: var(--link-color);
}

#results small {
    color: var(--meta-color);
}

#results span {
    color: var(--text-color);
    opacity: 0.8;
}

#feedback-section {
    margin-top: 2rem;
}

.feedback-note {
    color: var(--meta-color);
    margin-bottom: 0.75rem;
}

#feedback-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#feedback-honeypot {
    display: none;
}

#feedback-comment {
    min-height: 8rem;
    resize: vertical;
    padding: 0.85rem;
    font: inherit;
    color: var(--input-text);
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.feedback-upload {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: var(--meta-color);
    font-size: 0.95em;
}

.feedback-upload input[type="file"] {
    font: inherit;
    color: var(--input-text);
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.65rem;
}

.feedback-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

#feedback-submit {
    padding: 0.65rem 1rem;
    font: inherit;
    color: #ffffff;
    background: var(--link-color);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

#feedback-submit:disabled {
    opacity: 0.65;
    cursor: default;
}

#feedback-status {
    color: var(--meta-color);
    font-size: 0.9em;
}
