/* Animap — Field-journal aesthetic */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500;600&display=swap');

:root {
  --paper: #f3ebdc; --paper-2: #ebe1cc; --paper-3: #ddd0b4;
  --ink: #1f1b16; --ink-2: #3a3329; --ink-3: #6b604f; --ink-4: #9a8f7a;
  --rule: #c9bd9f;
  --moss: #3a5a40; --moss-dark: #2a4530;
  --rust: #a4442a; --rust-dark: #7e311c;
  --ochre: #b8863d; --faded-blue: #4a6d7c;
  --stamp: #8a3a1c;
  --serif: 'EB Garamond', Georgia, serif;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Inter', system-ui, sans-serif;
  --shadow-sm: 0 1px 0 rgba(31,27,22,0.06), 0 1px 2px rgba(31,27,22,0.04);
  --shadow-md: 0 2px 4px rgba(31,27,22,0.08), 0 6px 14px rgba(31,27,22,0.07);
  --shadow-lg: 0 10px 30px rgba(31,27,22,0.14), 0 2px 6px rgba(31,27,22,0.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); font-family: var(--serif); font-size: 17px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; min-height: 100vh; }
body.paper, .paper {
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, rgba(86,74,51,0.09) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(86,74,51,0.09) 1px, transparent 1px),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.4  0 0 0 0 0.25  0 0 0 0.06 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
  background-repeat: repeat, repeat, repeat;
  background-size: 24px 24px, 24px 24px, 240px 240px;
}

/* Positional dapple on a single fixed layer so it doesn't repaint during scroll. */
body.paper::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 18% 14%, rgba(184,134,61,0.07) 0%, transparent 40%),
    radial-gradient(circle at 84% 82%, rgba(58,90,64,0.06) 0%, transparent 46%),
    radial-gradient(ellipse 220px 80px at 74% 22%, rgba(138,102,58,0.07) 0%, transparent 70%);
  will-change: transform;
  transform: translateZ(0);
}
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
.mono { font-family: var(--mono); letter-spacing: 0.01em; }
.label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.rule-dotted { border: none; border-top: 1px dashed var(--rule); margin: 14px 0; }
.rule-double { border: none; height: 4px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); margin: 18px 0; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 2px; font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid var(--ink); background: transparent; color: var(--ink); transition: all 0.15s ease; }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; color: var(--ink); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--moss); border-color: var(--moss); }
.btn-moss { background: var(--moss); color: var(--paper); border-color: var(--moss); }
.btn-moss:hover { background: var(--moss-dark); border-color: var(--moss-dark); }
.btn-danger { background: var(--rust); color: var(--paper); border-color: var(--rust); }
.btn-danger:hover { background: var(--rust-dark); border-color: var(--rust-dark); }
.btn-ghost { border-color: var(--rule); color: var(--ink-2); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn-sm { padding: 6px 12px; font-size: 10.5px; }

.input { font-family: var(--serif); font-size: 17px; background: transparent; color: var(--ink); border: none; border-bottom: 1px solid var(--ink); padding: 8px 2px; outline: none; width: 100%; }
.input:focus { border-bottom-color: var(--moss); }
.input::placeholder { color: var(--ink-4); font-style: italic; }
.input-mono { font-family: var(--mono); font-size: 14px; }
.textarea { min-height: 110px; resize: vertical; border: 1px solid var(--rule); padding: 10px 12px; background: var(--paper); }
.textarea:focus { border-color: var(--moss); }

.stamp { display: inline-block; border: 2px solid var(--stamp); color: var(--stamp); padding: 4px 10px 3px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; font-weight: 600; transform: rotate(-3deg); border-radius: 2px; background: rgba(164,68,42,0.04); }
.stamp.moss { border-color: var(--moss); color: var(--moss); background: rgba(58,90,64,0.06); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--rule); background: var(--paper-2); font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); border-radius: 999px; }
.chip.moss { background: rgba(58,90,64,0.1); border-color: rgba(58,90,64,0.35); color: var(--moss-dark); }
.chip.rust { background: rgba(164,68,42,0.1); border-color: rgba(164,68,42,0.35); color: var(--rust-dark); }
.chip.blue { background: rgba(74,109,124,0.1); border-color: rgba(74,109,124,0.35); color: var(--faded-blue); }

.iucn-LC { color: #2e7b3b; } .iucn-NT { color: #85a02d; } .iucn-VU { color: #c89b2b; } .iucn-EN { color: #c76a1f; } .iucn-CR { color: #a4221f; } .iucn-DD, .iucn-EX { color: var(--ink-3); }

.sheet { background: var(--paper); border: 1px solid var(--rule); box-shadow: var(--shadow-md); }
.sepia-overlay { position: absolute; inset: 0; background: linear-gradient(rgba(243,235,220,0.14), rgba(164,68,42,0.06)); mix-blend-mode: multiply; pointer-events: none; }
.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(31,27,22,0.28) 100%); pointer-events: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pinPulse { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(2.4); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: fadeIn 0.3s ease both; }
.loader { width: 18px; height: 18px; border: 2px solid var(--rule); border-top-color: var(--moss); border-radius: 50%; animation: spin 0.8s linear infinite; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 10px; border: 2px solid var(--paper); }

/* App layout */
.shell { max-width: 1180px; margin: 0 auto; padding: 28px 32px 80px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 22px; border-bottom: 1px solid var(--ink); margin-bottom: 28px; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 22px; letter-spacing: 0.02em; }
.brand .dot { color: var(--rust); }
.topnav { display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.topnav-link { text-decoration: none; color: var(--ink-2); font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; padding: 2px 0; border-bottom: 1px solid transparent; transition: color 0.15s ease, border-color 0.15s ease; }
.topnav-link:hover { color: var(--ink); border-color: var(--ink-3); }
.masthead { text-align: center; padding: 24px 0 8px; }
.masthead h1 { font-family: var(--serif); font-weight: 500; font-size: 44px; margin: 0 0 6px; letter-spacing: 0.01em; }
.masthead .label { display: block; margin-bottom: 8px; }

.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; margin-top: 26px; }
.album-card { background: var(--paper); border: 1px solid var(--rule); box-shadow: var(--shadow-md); padding: 0; cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; display: flex; flex-direction: column; text-align: left; color: inherit; font: inherit; }
.album-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.album-card .cover { aspect-ratio: 4/3; background: var(--paper-3); position: relative; overflow: hidden; }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-card .cover .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink-4); font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.album-card .meta { padding: 14px 16px 16px; }
.album-card h3 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 20px; line-height: 1.15; }
.album-card .sub { margin-top: 4px; font-style: italic; color: var(--ink-3); font-size: 14px; }
.album-card .row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.split { display: grid; grid-template-rows: minmax(360px, 52vh) 1fr; gap: 28px; margin-top: 24px; }
.map-frame { position: relative; height: 100%; min-height: 360px; background: var(--paper-3); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.photo-tile { aspect-ratio: 1/1; position: relative; overflow: hidden; background: var(--paper-3); border: 1px solid var(--rule); cursor: pointer; padding: 0; text-align: left; color: inherit; font: inherit; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s ease; }
.photo-tile:hover img { transform: scale(1.04); }
.photo-tile .badge { position: absolute; left: 6px; bottom: 6px; right: 6px; background: rgba(31,27,22,0.78); color: var(--paper); padding: 4px 6px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; line-height: 1.25; text-transform: uppercase; }
.photo-tile .badge .nm { font-family: var(--serif); text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; }

.lightbox-backdrop { position: fixed; inset: 0; background: rgba(20,17,14,0.84); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 28px; }
.lightbox-close { position: absolute; top: 22px; right: 22px; z-index: 1; }
.lightbox-action { border-color: rgba(243,235,220,0.38); background: rgba(243,235,220,0.16); color: var(--paper); backdrop-filter: blur(3px); }
.lightbox-action:hover { background: rgba(243,235,220,0.28); color: var(--paper); border-color: rgba(243,235,220,0.58); }
.lightbox-panel { margin: 0; width: min(1160px, 100%); max-height: min(820px, calc(100vh - 56px)); display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr); overflow: hidden; background: rgba(33,28,23,0.96); border: 1px solid rgba(243,235,220,0.18); box-shadow: var(--shadow-lg); }
.lightbox-media { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 18px; background:
  radial-gradient(circle at top left, rgba(164,68,42,0.18), transparent 38%),
  radial-gradient(circle at bottom right, rgba(58,90,64,0.18), transparent 42%),
  rgba(12,10,8,0.88); }
.lightbox-image { display: block; max-width: 100%; max-height: calc(100vh - 92px); width: auto; height: auto; border: 1px solid rgba(243,235,220,0.22); box-shadow: var(--shadow-lg); background: rgba(0,0,0,0.24); }
.lightbox-sidebar { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); color: var(--paper); background: linear-gradient(180deg, rgba(243,235,220,0.08), rgba(243,235,220,0.03)); border-left: 1px solid rgba(243,235,220,0.12); }
.lightbox-header { padding: 26px 24px 18px; border-bottom: 1px solid rgba(243,235,220,0.12); }
.lightbox-title { font-family: var(--serif); font-size: 26px; line-height: 1.1; }
.lightbox-meta { margin-top: 4px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(243,235,220,0.78); }
.lightbox-note { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(243,235,220,0.12); font-size: 15px; line-height: 1.65; color: rgba(243,235,220,0.86); white-space: pre-wrap; }
.lightbox-body { min-height: 0; overflow-y: auto; padding: 22px 24px 26px; }
.lightbox-facts { display: grid; gap: 12px; margin-bottom: 18px; }
.lightbox-fact { padding: 10px 12px; border: 1px solid rgba(243,235,220,0.12); background: rgba(243,235,220,0.04); }
.lightbox-description { font-size: 16px; line-height: 1.7; color: rgba(243,235,220,0.92); white-space: pre-wrap; }
.lightbox-empty { font-size: 15px; line-height: 1.6; color: rgba(243,235,220,0.62); font-style: italic; }

/* signin */
.signin-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.signin-card { width: 100%; max-width: 460px; background: var(--paper); border: 1px solid var(--ink); box-shadow: var(--shadow-lg); padding: 36px 36px 32px; position: relative; }
.signin-card .stamp { position: absolute; top: -18px; right: 22px; }
.signin-card h2 { font-family: var(--serif); font-weight: 500; font-size: 30px; margin: 0 0 8px; }
.signin-card p { color: var(--ink-3); font-style: italic; margin: 0 0 22px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(31,27,22,0.55); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 20px; }
.modal-card { background: var(--paper); border: 1px solid var(--ink); box-shadow: var(--shadow-lg); max-width: 540px; width: 100%; max-height: 92vh; overflow-y: auto; }
.modal-card .head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--rule); }
.modal-card .head h3 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 22px; }
.modal-card .body { padding: 22px; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field .label { margin: 0; }
.field .row { display: flex; gap: 12px; }
.field .row > * { flex: 1; }
.segmented { display: inline-flex; align-self: flex-start; border: 1px solid var(--rule); background: var(--paper-2); }
.segmented-option { border: 0; background: transparent; color: var(--ink-2); padding: 10px 14px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
.segmented-option + .segmented-option { border-left: 1px solid var(--rule); }
.segmented-option.active { background: var(--moss); color: var(--paper); }

.flash { padding: 10px 14px; border: 1px solid var(--rule); background: var(--paper-2); margin-top: 10px; font-size: 14px; color: var(--ink-2); }
.flash.err { border-color: rgba(164,68,42,0.55); color: var(--rust-dark); background: rgba(164,68,42,0.08); }
.flash.ok { border-color: rgba(58,90,64,0.45); color: var(--moss-dark); background: rgba(58,90,64,0.08); }

@media (max-width: 860px) {
  .shell { padding: 18px 18px 60px; }
  .topbar { gap: 12px; flex-wrap: wrap; }
  .album-grid { grid-template-columns: 1fr; }
  .split { grid-template-rows: 320px 1fr; gap: 18px; }
  .map-frame { min-height: 320px; }
  .modal-card { max-width: 100%; }
  .lightbox-backdrop { padding: 18px; }
  .lightbox-close { top: 16px; right: 16px; }
  .lightbox-panel { grid-template-columns: 1fr; max-height: calc(100vh - 36px); }
  .lightbox-media { padding: 14px 14px 8px; }
  .lightbox-image { max-height: 42vh; }
  .lightbox-sidebar { border-left: 0; border-top: 1px solid rgba(243,235,220,0.12); }
  .lightbox-header { padding: 18px 18px 14px; }
  .lightbox-body { padding: 16px 18px 20px; }
  .lightbox-title { font-size: 22px; }
  .lightbox-description { font-size: 15px; }
}

/* ---------- Field-journal flourishes ---------- */

/* Survey-plate corner brackets around the map (like a specimen mount). */
.map-frame { position: relative; }
.map-frame::before {
  content: '';
  position: absolute;
  inset: -8px;
  pointer-events: none;
  z-index: 4;
  background:
    linear-gradient(var(--ink), var(--ink)) top    left  / 22px 2px  no-repeat,
    linear-gradient(var(--ink), var(--ink)) top    left  / 2px  22px no-repeat,
    linear-gradient(var(--ink), var(--ink)) top    right / 22px 2px  no-repeat,
    linear-gradient(var(--ink), var(--ink)) top    right / 2px  22px no-repeat,
    linear-gradient(var(--ink), var(--ink)) bottom left  / 22px 2px  no-repeat,
    linear-gradient(var(--ink), var(--ink)) bottom left  / 2px  22px no-repeat,
    linear-gradient(var(--ink), var(--ink)) bottom right / 22px 2px  no-repeat,
    linear-gradient(var(--ink), var(--ink)) bottom right / 2px  22px no-repeat;
}

/* Slide-mount tick marks inside paper sheets. */
.sheet { position: relative; }
.sheet::before {
  content: '';
  position: absolute;
  inset: 7px;
  pointer-events: none;
  opacity: 0.45;
  z-index: 0;
  background:
    linear-gradient(var(--ink-3), var(--ink-3)) top    left  / 12px 1px no-repeat,
    linear-gradient(var(--ink-3), var(--ink-3)) top    left  / 1px 12px no-repeat,
    linear-gradient(var(--ink-3), var(--ink-3)) top    right / 12px 1px no-repeat,
    linear-gradient(var(--ink-3), var(--ink-3)) top    right / 1px 12px no-repeat,
    linear-gradient(var(--ink-3), var(--ink-3)) bottom left  / 12px 1px no-repeat,
    linear-gradient(var(--ink-3), var(--ink-3)) bottom left  / 1px 12px no-repeat,
    linear-gradient(var(--ink-3), var(--ink-3)) bottom right / 12px 1px no-repeat,
    linear-gradient(var(--ink-3), var(--ink-3)) bottom right / 1px 12px no-repeat;
}

/* Ornamental rule — alternate to .rule-double with central compass glyph. */
.rule-compass { display: flex; align-items: center; gap: 14px; margin: 18px 0; }
.rule-compass::before, .rule-compass::after {
  content: ''; flex: 1; height: 0;
  border-top: 1px solid var(--ink);
}
.rule-compass > .mark {
  width: 18px; height: 18px; flex: 0 0 auto;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%231f1b16' stroke-width='0.8'><circle cx='10' cy='10' r='7'/><path d='M10 2 L11.6 10 L10 18 L8.4 10 Z' fill='%23a4442a' stroke-width='0.4'/><circle cx='10' cy='10' r='1' fill='%231f1b16'/></svg>") center / contain no-repeat;
}

/* Field tag — small punched-tag chip for coordinates / specimen numbers. */
.field-tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 20px;
  border: 1px solid var(--ink);
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  position: relative;
  box-shadow: var(--shadow-sm);
}
.field-tag::before {
  content: '';
  position: absolute; left: 7px; top: 50%;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--ink);
  transform: translateY(-50%);
}

/* Letterpress feel on buttons when pressed. */
.btn:active { transform: translateY(1px); }
.btn-primary:active, .btn-moss:active, .btn-danger:active {
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.35);
}
.btn-ghost:active, .btn:active:not(.btn-primary):not(.btn-moss):not(.btn-danger) {
  box-shadow: inset 0 1px 2px rgba(31,27,22,0.14);
}

/* Subtle field-plate vignette on photo thumbnails (like a mounted specimen). */
.photo-tile { box-shadow: inset 0 0 0 1px rgba(31,27,22,0.06), var(--shadow-sm); }
.photo-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 78%, rgba(31,27,22,0.22) 100%);
  mix-blend-mode: multiply;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}
.photo-tile:hover::after { opacity: 0.25; }
.photo-tile .badge { z-index: 2; }

/* Album cover — add a small "sighting no." style stamp on each card. */
.album-card .cover { position: relative; }
.album-card .cover::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(31,27,22,0) 60%, rgba(31,27,22,0.18) 100%),
    radial-gradient(ellipse at top right, rgba(184,134,61,0.10), transparent 55%);
}

/* Brand tweak: give the punctuation dot a compass-needle red. */
.brand { display: inline-flex; align-items: baseline; }
.brand .dot { color: var(--rust); margin-left: 1px; }

/* Stamp — slight ink-spread shadow so it reads like a real rubber stamp. */
.stamp { text-shadow: 0 0 0.5px currentColor; box-shadow: 0 0 0 1px rgba(138,58,28,0.04); }

@media (max-width: 860px) {
  .map-frame::before { inset: -5px; background-size:
    16px 2px, 2px 16px, 16px 2px, 2px 16px,
    16px 2px, 2px 16px, 16px 2px, 2px 16px; }
}
