/* The shared design system: tokens, the controls both surfaces use, and the
 * styles for the markup lib/render.js builds.
 *
 * Loaded by the extension's sidepanel.html and the Drive app's index.html. Each
 * of those adds only its own shell — header, footer, and how the page is laid
 * out. Anything render.js can emit belongs here, or the two surfaces drift.
 *
 * Deliberately does not set font-size: the panel is 320-500px and reads at
 * 13px, a browser tab does not. Each surface sets its own on body.
 */

/* Palette lifted from the online tool at
 * exifviewerapp.com/online-exif-metadata-viewer, so the web tool, the panel and
 * the Drive app are one family in both themes.
 *
 * Light is the default and dark is applied via [data-theme="dark"], matching
 * the web tool. lib/theme-init.js sets that attribute before first paint.
 *
 * Two accents, and the distinction matters: --accent is for text, marks and
 * links, --accent-fill is for button backgrounds. The brand yellow is legible
 * on a dark ground but not on white, so light mode uses a darker amber for
 * anything that has to be *read* while keeping the yellow for anything that is
 * merely *seen*.
 */
:root {
  /* LIGHT — warm paper / lightbox */
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface2: #f1ece2;
  --border: #e4dfd4;
  --text: #1b1d21;
  --muted: #5f656c;
  --accent: #9a5c0e;
  --accent-fill: #ecd72e;
  --ink: #1c1503;
  --warn: #b4761f;
  --alert: #c4432f;
  color-scheme: light;
}

:root[data-theme="dark"] {
  /* DARK — charcoal / darkroom under safelight */
  --bg: #101214;
  --surface: #17191d;
  --surface2: #1d2025;
  --border: #2a2e34;
  --text: #e8e4dc;
  --muted: #939aa4;
  --accent: #e8a33d;
  --accent-fill: #ecd72e;
  --ink: #1c1503;
  --warn: #d08a24;
  --alert: #e4695a;
  color-scheme: dark;
}

/* Only the colours move, so nothing reflows when the theme changes. */
body,
.btn,
.notice,
.section,
.filter,
.card {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* Both surfaces toggle the `hidden` attribute rather than inline styles. */
[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

/* Theme toggle. Same control on both surfaces and on the web tool: a round
 * icon button that shows where you are going, not where you are — a moon while
 * light means "go dark". lib/theme-init.js owns the behaviour. */
.theme-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.theme-toggle:hover {
  border-color: var(--muted);
  color: var(--text);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.theme-toggle .ic-sun {
  display: none;
}

.theme-toggle .ic-moon {
  display: block;
}

[data-theme="dark"] .theme-toggle .ic-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .ic-moon {
  display: none;
}

/* Buttons */

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
}

/* The muted grey reads as "one step darker than the resting border" in dark and
 * "one step firmer" in light, which a fixed hex cannot do in both. */
.btn:hover {
  border-color: var(--muted);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-small {
  padding: 5px 9px;
  font-size: 12px;
}

/* For the one action on a screen that is worth being unmissable. */
.btn-large {
  padding: 12px 26px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
}

/* The brand yellow, in both themes — it is a background here, not something
 * anyone has to read, and --ink stays legible on it either way. */
.btn-primary {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--ink);
  font-weight: 600;
}

.btn-primary:hover {
  border-color: var(--accent-fill);
  filter: brightness(1.06);
}

/* Result header */

.file-bar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.file-meta {
  min-width: 0;
}

.file-name {
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-bar .muted {
  font-size: 12px;
}

/* Preview */

.preview {
  margin: 0 0 12px;
}

.preview img {
  width: auto;
  max-height: 420px;
  margin: 0 auto;
  display: block;
  max-width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Notices */

.notice {
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: var(--surface);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.notice-info {
  border-left-color: var(--accent);
}

.notice-warn {
  border-left-color: var(--warn);
}

.notice-error {
  border-left-color: var(--alert);
}

.notice-heading {
  margin: 0 0 4px;
  font-weight: 600;
}

.notice-body {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.notice-body:last-child {
  margin-bottom: 0;
}

/* Disclosure for a notice whose explanation starts hidden. Styled as a link
   rather than a button: it reveals text, it does not do anything. */
.notice-toggle {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 2px 0 0;
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.notice-toggle:hover {
  text-decoration: underline;
}

.notice-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Same triangle as a section heading, so the affordance reads the same. */
.notice-toggle::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.12s ease;
}

.notice-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.notice-details {
  margin-top: 8px;
}

.notice-action {
  margin-top: 10px;
}

/* Actions */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

/* Sections — everything below is markup lib/render.js builds. */

.section {
  border-top: 1px solid var(--border);
}

.section summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.section summary::-webkit-details-marker {
  display: none;
}

/* Disclosure triangle, drawn rather than shipped as an asset. */
.section summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.12s ease;
}

.section[open] summary::before {
  transform: rotate(90deg);
}

.section summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.section-title {
  font-weight: 600;
  flex: 1 1 auto;
}

.section-count {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.section-body {
  padding: 2px 2px 14px;
}

/* Key/value rows */

.rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kv {
  display: grid;
  grid-template-columns: minmax(96px, 38%) 1fr;
  gap: 10px;
  align-items: start;
}

.kv-key {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.kv-value {
  overflow-wrap: anywhere;
}

.maps-link {
  display: inline-block;
  margin-top: 10px;
}

/* All tags */

.filter {
  width: 100%;
  margin-bottom: 12px;
  padding: 6px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.filter:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.tag-group + .tag-group {
  margin-top: 14px;
}

.tag-group-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 5px;
  border-bottom: 1px solid var(--accent);
}

.tag-group .kv-value {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}
