/* The admin site: the stone, ink, copper and water of banos-califales-web, with plain forms for editing one thing at
   a time. */

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/ibm-plex-sans/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/ibm-plex-sans/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('/fonts/ibm-plex-sans/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/cormorant-garamond/cormorant-garamond-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('/fonts/cormorant-garamond/cormorant-garamond-latin-500-italic.woff2') format('woff2');
  font-style: italic;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: 'Cormorant SC';
  src: url('/fonts/cormorant-sc/cormorant-sc-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: Lora;
  src: url('/fonts/lora/lora-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  --stone-canvas: #f2eee6;
  --stone-raised: #faf8f3;
  --stone-soft: #e8e0d3;
  --stone-line: #d9cfbf;
  --ink-deep: #17211f;
  --ink-body: #34423e;
  --ink-muted: #596560;
  --water-deep: #274b4f;
  --water-soft: #dfe9e7;
  --copper: #a5653f;
  --copper-deep: #78462f;
  --copper-soft: #f4e4d8;
  --highlight-surface: #f6d9d5;
  --highlight-line: #b85b51;
  --highlight-ink: #842e29;
  --focus-ring: #c88050;
  --line-light: rgb(23 33 31 / 12%);
  --line-dark: rgb(250 248 243 / 14%);
  --font-display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --font-label: 'Cormorant SC', 'Cormorant Garamond', Georgia, serif;
  --font-body: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  --font-text: Lora, Georgia, serif;
  --radius: 6px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  background: var(--stone-canvas);
  color: var(--ink-body);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  scrollbar-gutter: stable;
}

body { min-width: 320px; margin: 0; }

:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }

a { color: var(--water-deep); }

code {
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--stone-soft);
  color: var(--ink-deep);
  font-size: .86em;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-160%);
  background: var(--ink-deep);
  color: var(--stone-raised);
}

.skip-link:focus { transform: none; }

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

.admin-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 32px;
  padding: 12px max(16px, calc((100% - 1240px) / 2));
  border-bottom: 1px solid var(--line-dark);
  background: var(--ink-deep);
  color: var(--stone-raised);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.admin-brand-mark {
  width: 26px;
  height: 30px;
  flex: none;
  border: 3px solid var(--stone-raised);
  border-bottom-width: 6px;
  border-radius: 13px 13px 2px 2px;
  background: radial-gradient(circle at 50% 42%, var(--copper) 0 3px, transparent 4px);
}

.admin-brand-copy { display: grid; line-height: 1.1; }

.admin-brand-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }

.admin-brand-subtitle {
  color: var(--copper-light, #d9a47e);
  font-family: var(--font-label);
  font-size: .95rem;
  letter-spacing: .08em;
}

.admin-nav { display: flex; flex-wrap: wrap; gap: 4px; }

.admin-nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: rgb(250 248 243 / 78%);
  text-decoration: none;
}

.admin-nav a:hover { color: var(--stone-raised); background: rgb(250 248 243 / 8%); }

.admin-nav a[aria-current='page'] { color: var(--ink-deep); background: var(--stone-raised); }

.admin-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 0 auto;
  color: rgb(250 248 243 / 72%);
  font-size: .9rem;
}

.admin-logout button {
  padding: 5px 12px;
  border: 1px solid rgb(250 248 243 / 30%);
  border-radius: 999px;
  background: transparent;
  color: var(--stone-raised);
  font: inherit;
  cursor: pointer;
}

.admin-logout button:hover { border-color: var(--copper); }

/* ── Page ────────────────────────────────────────────────────────────── */

.admin-main {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 28px 16px 80px;
}

.page-heading { margin-bottom: 24px; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--water-deep);
  font-family: var(--font-label);
  font-size: 1rem;
  letter-spacing: .1em;
}

h1, h2, h3 { color: var(--ink-deep); font-family: var(--font-display); font-weight: 600; line-height: 1.15; }

h1 { margin: 0; font-size: clamp(2rem, 4vw, 2.6rem); }

h2 { margin: 0 0 12px; font-size: 1.6rem; }

h3 { margin: 0; font-size: 1.25rem; }

.lead { max-width: 75ch; margin: 8px 0 0; color: var(--ink-muted); }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  color: var(--ink-muted);
  font-size: .9rem;
  list-style: none;
}

.breadcrumb li + li::before { content: '/'; margin-right: 6px; color: var(--stone-line); }

.card {
  margin-bottom: 20px;
  padding: 22px 24px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  background: var(--stone-raised);
}

.card-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.card-heading h2 { margin: 0; }

.card-heading h2::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 10px 4px 0;
  transform: rotate(45deg);
  background: var(--water-deep);
  content: '';
}

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

.spaced { margin-top: 20px; }

.spaced-small { margin-top: 12px; }

.legend { margin-bottom: 6px; padding: 0; }

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 12px 0 0;
}

.facts div { display: grid; }

.facts dt { color: var(--water-deep); font-family: var(--font-label); letter-spacing: .08em; }

.facts dd { margin: 0; color: var(--ink-deep); }

/* ── Notices ─────────────────────────────────────────────────────────── */

.notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-left: 4px solid var(--water-deep);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--water-soft);
  color: var(--ink-deep);
}

.notice-error { border-color: var(--copper-deep); background: var(--copper-soft); }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--copper-soft);
  color: var(--copper-deep);
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-ok { background: var(--water-soft); color: var(--water-deep); }

/* ── Forms ───────────────────────────────────────────────────────────── */

/* align-content keeps a field at its own height when its neighbour in the row is taller */
.field { display: grid; align-content: start; gap: 4px; margin: 0; }

.field + .field { margin-top: 12px; }

.field-label {
  color: var(--ink-deep);
  font-weight: 500;
  font-size: .9rem;
}


.field-hint { color: var(--ink-muted); font-size: .85rem; font-weight: 400; }

input[type='text'], input[type='password'], input[type='number'], input[type='search'], select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--stone-line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink-deep);
  font: inherit;
}

textarea { resize: vertical; line-height: 1.45; }

/* Textareas that grow with their text, keeping their rows as the least height (16px: padding and border). Browsers
   without field-sizing get the height from admin.mjs. */
textarea[data-autosize] { field-sizing: content; }

textarea[data-autosize][rows='2'] { min-block-size: calc(2lh + 16px); }

textarea[data-autosize][rows='3'] { min-block-size: calc(3lh + 16px); }

textarea[data-autosize][rows='4'] { min-block-size: calc(4lh + 16px); }

textarea[data-autosize][rows='5'] { min-block-size: calc(5lh + 16px); }

input:focus, select:focus, textarea:focus { border-color: var(--copper); outline: 2px solid rgb(200 128 80 / 35%); }

input[aria-invalid='true'], textarea[aria-invalid='true'] { border-color: var(--copper-deep); }

.lang-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* In the two-column grid the gap spaces the fields, so both languages start at the same height */
.lang-pair > .field + .field { margin-top: 0; }

@media (max-width: 760px) {
  .lang-pair { grid-template-columns: 1fr; }
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 14px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 18px;
  border: 1px solid var(--ink-deep);
  border-radius: 3px;
  background: var(--ink-deep);
  color: var(--stone-raised);
  font-family: var(--font-label);
  font-size: 1.02rem;
  letter-spacing: .1em;
  text-decoration: none;
  cursor: pointer;
}

.button:hover { background: var(--water-deep); border-color: var(--water-deep); }

.button-ghost { background: transparent; color: var(--ink-deep); }

.button-ghost:hover { background: var(--stone-soft); border-color: var(--ink-deep); }

.button-small { min-height: 30px; padding: 0 10px; font-size: .92rem; }

.button-danger { border-color: var(--copper-deep); background: transparent; color: var(--copper-deep); }

.button-danger:hover { background: var(--copper-deep); border-color: var(--copper-deep); color: var(--stone-raised); }

.button[disabled] { opacity: .5; cursor: not-allowed; }

.dirty-flag { display: none; color: var(--copper-deep); font-size: .85rem; }

form.is-dirty .dirty-flag { display: inline; }

/* ── Login ───────────────────────────────────────────────────────────── */

.login {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, var(--ink-deep), var(--water-deep));
}

.login-card { width: min(400px, 100%); padding: 32px; border-radius: var(--radius); background: var(--stone-raised); }

.login-card .admin-brand { color: var(--ink-deep); margin-bottom: 20px; }

.login-card .admin-brand-mark { border-color: var(--ink-deep); }

.login-card .admin-brand-subtitle { color: var(--copper-deep); }

.login-card .button { width: 100%; margin-top: 18px; }

/* ── Home ────────────────────────────────────────────────────────────── */

.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

.home-grid .card { display: flex; flex-direction: column; margin: 0; }

.home-grid .card p { flex: 1; }

.home-number { margin: 0; color: var(--copper-deep); font-family: var(--font-display); font-size: 3rem; line-height: 1; }

/* ── Tables ──────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th, td { padding: 8px 10px; border-bottom: 1px solid var(--line-light); text-align: left; vertical-align: middle; }

th { color: var(--water-deep); font-family: var(--font-label); font-size: 1rem; font-weight: 600; letter-spacing: .06em; }

td input[type='text'] { min-width: 90px; }

.zone-number {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink-deep);
  color: var(--stone-raised);
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.row-title { display: grid; }

.row-title small { color: var(--ink-muted); }

/* ── Texts ───────────────────────────────────────────────────────────── */

.texts-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; }

@media (max-width: 900px) {
  .texts-layout { grid-template-columns: 1fr; }
}

.texts-index {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  background: var(--stone-raised);
}

@media (max-width: 900px) {
  .texts-index { position: static; max-height: none; }
}

.texts-index ol { margin: 12px 0 0; padding: 0; list-style: none; }

.texts-index a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 3px;
  color: var(--ink-body);
  font-size: .9rem;
  text-decoration: none;
}

.texts-index a:hover { background: var(--stone-soft); }

.texts-index span:last-child { color: var(--ink-muted); }

/* Room for the header and the save bar above a text the page scrolls to */
.text-section { margin-bottom: 32px; scroll-margin-top: 150px; }

.text-section > h2 {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--stone-line);
}

.text-card {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line-light);
  border-radius: var(--radius);
  background: var(--stone-raised);
  scroll-margin-top: 150px;
}

.text-card.is-saved { border-color: var(--water-deep); box-shadow: 0 0 0 2px var(--water-soft); }

.text-card.is-highlighted { border-color: var(--highlight-line); background: var(--highlight-surface); }

.text-card header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }

.text-card h3 { font-family: var(--font-body); font-size: .98rem; font-weight: 600; }

.text-card header code { color: var(--ink-muted); background: none; padding: 0; font-size: .78rem; }

.text-card .lang-pair { margin-top: 8px; }

.text-card .form-actions { margin-top: 8px; }

.text-highlight { gap: 6px; }

.text-highlight-check { visibility: hidden; font-family: var(--font-body); }

.text-highlight[aria-pressed='true'] { border-color: var(--highlight-ink); color: var(--highlight-ink); }

.text-highlight[aria-pressed='true'] .text-highlight-check { visibility: visible; }

.text-card[hidden], .text-section[hidden] { display: none; }

/* In the form of every text, only the cards that changed say so */
.texts-form.is-dirty .dirty-flag { display: none; }

.texts-form .text-card.is-dirty .dirty-flag { display: inline; }

/* The bar that saves every changed text: under the header while there is something to save. Without scripting the
   page cannot tell, so it is always there. On narrow screens the header takes several rows, so it sits at the bottom. */
.save-bar {
  position: sticky;
  z-index: 10;
  top: 84px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid var(--copper);
  border-radius: var(--radius);
  background: var(--copper-soft);
  box-shadow: 0 6px 16px rgb(23 33 31 / 14%);
}

.save-bar p { margin: 0; color: var(--ink-deep); font-weight: 500; }

.save-bar-idle { display: none; }

@media (scripting: enabled) {
  .texts-form:not(.is-dirty) .save-bar { display: none; }
}

@media (scripting: none) {
  .save-bar-pending { display: none; }

  .save-bar-idle { display: inline; }
}

@media (max-width: 900px) {
  .save-bar { position: fixed; inset: auto 16px 16px; margin: 0; }

  .texts-form { padding-bottom: 72px; }
}

.notice ul { margin: 6px 0 0; padding-left: 20px; }

.notice p { margin: 0; }

/* ── Texts: developer mode (the texts of one language as a JSON file) ── */

.dev-mode {
  margin-bottom: 20px;
  padding: 10px 16px;
  border: 1px dashed var(--stone-line);
  border-radius: var(--radius);
  background: var(--stone-raised);
}

.dev-mode summary { color: var(--ink-deep); font-weight: 600; cursor: pointer; }

.dev-mode-form { display: grid; gap: 12px; max-width: 760px; margin-top: 12px; }

.dev-mode-form .field + .field { margin-top: 0; }

.dev-mode-language { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0; padding: 0; border: 0; }

.dev-mode-language legend { margin-bottom: 4px; padding: 0; font-weight: 600; }

.dev-mode-language label { display: inline-flex; align-items: center; gap: 6px; }

.dev-mode textarea { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

/* The problems that stop an import come one per line */
.import-error { white-space: pre-line; }

.import-table-wrap { max-block-size: min(70vh, 900px); overflow: auto; container-type: inline-size; }

.import-table caption { margin-bottom: 8px; color: var(--ink-deep); font-weight: 600; text-align: left; }

.import-table thead th { position: sticky; z-index: 1; top: 0; background: var(--stone-raised); }

.import-table tbody th, .import-table td { vertical-align: top; white-space: pre-wrap; }

.import-table tbody th { color: var(--ink-deep); font-family: var(--font-body); font-size: .9rem; letter-spacing: 0; }

.import-table tbody th code { display: block; margin-top: 2px; color: var(--ink-muted); font-size: .78rem; }

.import-table td:last-child { background: var(--water-soft); }

/* Narrow: each text becomes a card with its two versions labelled */
@container (width < 640px) {
  .import-table, .import-table tbody, .import-table tr, .import-table th, .import-table td { display: block; }

  .import-table thead { display: none; }

  .import-table tr { margin-bottom: 12px; border: 1px solid var(--line-light); border-radius: var(--radius); }

  .import-table td::before { display: block; color: var(--water-deep); font-family: var(--font-label); font-weight: 600; }

  .import-table td:nth-child(2)::before { content: 'Ahora'; }

  .import-table td:nth-child(3)::before { content: 'Con el archivo'; }
}

/* ── Zone layout ─────────────────────────────────────────────────────── */

.panorama-box {
  position: relative;
  height: clamp(320px, 52vh, 560px);
  margin: 12px 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--ink-deep);
}

/* Pannellum sizes its container to 100% of its parent, so the view fills the sized box */
.panorama-view { position: absolute; inset: 0; }

.panorama-box .pnlm-container { background: var(--ink-deep); }

.panorama-banner {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 50%;
  max-width: calc(100% - 24px);
  padding: 8px 14px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--copper);
  color: #fff;
  font-size: .9rem;
  pointer-events: none;
}

.panorama-view.is-placing, .panorama-view.is-placing .pnlm-dragfix { cursor: crosshair; }

.admin-hotspot {
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 2px solid #fff;
  border-radius: 6px;
  background: rgb(39 75 79 / 85%);
  box-shadow: 0 2px 6px rgb(0 0 0 / 45%);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 26px;
  text-align: center;
}

.admin-hotspot-link { border-radius: 50%; background: rgb(165 101 63 / 90%); }

.admin-hotspot.is-active { outline: 3px solid #ffd9a8; }

.admin-hotspot span {
  position: absolute;
  top: 32px;
  left: 50%;
  padding: 2px 8px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: rgb(23 33 31 / 85%);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.layout-row.is-active { background: var(--copper-soft); }

.coordinate { width: 92px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.layout-tables { display: grid; gap: 18px; }

.layout-tables h3 { margin: 6px 0 4px; }

.new-point { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }

/* ── Point editor ────────────────────────────────────────────────────── */

.type-choice { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; border: 0; }

.type-choice label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--stone-line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.type-choice label:has(input:checked) { border-color: var(--water-deep); box-shadow: inset 0 0 0 1px var(--water-deep); }

.repeat-item {
  position: relative;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line-light);
  border-radius: 4px;
  background: #fff;
}

.repeat-item-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 8px; }

.image-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; }

@media (max-width: 640px) {
  .image-row { grid-template-columns: 1fr; }
}

.image-preview {
  width: 120px;
  height: 90px;
  border-radius: 3px;
  background: var(--stone-soft);
  object-fit: cover;
}




.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }

.sheet-grid .wide { grid-column: 1 / -1; }

@media (max-width: 760px) {
  .sheet-grid { grid-template-columns: 1fr; }
}

.sheet-group { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-light); }

.sheet-group > h3 { font-size: 1.15rem; }

.sheet-group > p { margin: 2px 0 0; }


.sticky-actions {
  position: sticky;
  z-index: 10;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 -24px -22px;
  padding: 12px 24px;
  border-top: 1px solid var(--line-light);
  border-radius: 0 0 var(--radius) var(--radius);
  background: rgb(250 248 243 / 96%);
}

.error-page { max-width: 640px; margin: 60px auto; }
