/* ---- palette ---------------------------------------------------------- */
:root {
  color-scheme: dark;
  /* AppFlowy dark theme */
  --paper: #1a202c;        /* page background */
  --paper-deep: #232b38;   /* panels, code, callouts */
  --ink: #e2e9f2;          /* main text */
  --ink-soft: #8d9aab;     /* captions */
  --rule: #313b4a;         /* lines */
  --accent: #00bcf0;       /* AppFlowy blue */
  --accent-soft: #0f3a4a;
  --good: #66cf80;
  --font-display: "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --measure: none;       /* reading column width (none = use full width) */
  --gutter: 2.5rem;      /* side padding, shrinks on small screens */
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  word-break: break-word;
}

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-soft); }
a:hover { border-bottom-color: var(--accent); }

/* ---- masthead --------------------------------------------------------- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.masthead__inner {
  max-width: none;
  margin: 0 auto;
  padding: 0.85rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  border: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand__mark {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0.28rem 0.28rem 0 var(--accent-soft);
}

.masthead__tools {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-deep);
}

.status__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 18%, transparent);
}

.status[data-state="stale"] .status__dot { background: #c98a1b; box-shadow: 0 0 0 3px #4a3a14; }
.status[data-state="error"] .status__dot { background: #b4342d; box-shadow: 0 0 0 3px #4a1f1c; }

.ghost {
  font: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}
.ghost:hover { background: var(--paper-deep); border-color: var(--accent); }
.ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- sheet ------------------------------------------------------------ */
.sheet {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3.5rem var(--gutter) 5rem;
}

.placeholder { color: var(--ink-soft); font-style: italic; }

.doc > :first-child { margin-top: 0; }

/* ---- headings --------------------------------------------------------- */
.doc h1, .doc h2, .doc h3, .doc h4, .doc h5, .doc h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.015em;
  margin: 0.7rem 0 0rem;
  scroll-margin-top: 5rem;
}

.doc h1 {
  font-size: clamp(2.1rem, 5vw, 2.9rem);
  font-weight: 700;
  margin-top: 0;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--ink);
}
.doc h2 { font-size: 1.62rem; }
.doc h3 { font-size: 1.28rem; }
.doc h4 { font-size: 1.08rem; }
.doc h5, .doc h6 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }

.doc p { margin: 0 0 1.05rem; }
.doc strong { font-weight: 700; }
.doc em { font-style: italic; }
.doc s { color: var(--ink-soft); }

.doc code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.08em 0.36em;
}

.doc pre {
  margin: 1.4rem 0;
  padding: 1.1rem 1.2rem;
  background: #11151d;
  color: #f2ece2;
  border-radius: 6px;
  overflow: auto;
  line-height: 1.6;
}
.doc pre code { background: none; border: 0; padding: 0; color: inherit; font-size: 0.84rem; }

.doc blockquote {
  margin: 1.5rem 0;
  padding: 0.2rem 0 0.2rem 1.2rem;
  border-left: 3px solid var(--accent);
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-style: italic;
  color: var(--ink-soft);
}
.doc blockquote p { margin: 0 0 0.6rem; }
.doc blockquote p:last-child { margin-bottom: 0; }

.doc hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.6rem auto;
  width: 6rem;
}

/* ---- lists ------------------------------------------------------------ */
.doc ul, .doc ol { margin: 0 0 1.2rem; padding-left: 1.35rem; }
.doc li { margin: 0.3rem 0; padding-left: 0.25rem; }
.doc ul { list-style: none; padding-left: 1.15rem; }
.doc ul > li { position: relative; }
.doc ul > li::before {
  content: "";
  position: absolute;
  left: -0.95rem;
  top: 0.72em;
  width: 0.34rem;
  height: 0.34rem;
  border-radius: 1px;
  transform: rotate(45deg);
  background: var(--accent);
}
.doc ol { list-style: decimal; }
.doc ol > li::marker { font-family: var(--font-display); font-weight: 600; color: var(--accent); }

.doc ul.ul--todo { padding-left: 0.2rem; list-style: none; }
.doc ul.ul--todo > li { display: flex; gap: 0.6rem; align-items: flex-start; }
.doc ul.ul--todo > li::before { display: none; }
.doc .check {
  display: inline-block;
  flex: 0 0 auto;
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.32em;
  border: 1.5px solid var(--ink-soft);
  border-radius: 3px;
  background: var(--paper-deep);
  position: relative;
}
.doc .check[data-checked="true"] { background: var(--accent); border-color: var(--accent); }
.doc .check[data-checked="true"]::after {
  content: "";
  position: absolute;
  left: 0.28rem;
  top: 0.05rem;
  width: 0.28rem;
  height: 0.55rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.doc .is-done > .body { color: var(--ink-soft); text-decoration: line-through; }

/* ---- callout, image, toggle ------------------------------------------- */
.doc aside.note {
  --note-accent: #8d9aab;
  position: relative;
  margin: 1.7rem 0;
  padding: 1rem 1.2rem 1rem 1.1rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background:
    linear-gradient(
      color-mix(in srgb, var(--note-accent) 13%, var(--paper)),
      color-mix(in srgb, var(--note-accent) 8%, var(--paper))
    );
  border: 1px solid color-mix(in srgb, var(--note-accent) 32%, transparent);
  border-left: 3px solid var(--note-accent);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.doc .note__icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  margin-top: 0.05rem;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 9px;
  background: color-mix(in srgb, var(--note-accent) 20%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--note-accent) 30%, transparent);
}
.doc .note__inner { flex: 1 1 auto; min-width: 0; }
.doc .note__inner > :first-child { margin-top: 0; }
.doc .note__inner > :last-child { margin-bottom: 0; }

/* callout variants — the accent colour drives tint, border, and icon badge */
.doc .note--info   { --note-accent: #4aa3ff; }
.doc .note--gray   { --note-accent: #9aa4b2; }
.doc .note--brown  { --note-accent: #b08968; }
.doc .note--orange { --note-accent: #ff9f43; }
.doc .note--yellow { --note-accent: #f5c518; }
.doc .note--green  { --note-accent: #5ec27a; }
.doc .note--blue   { --note-accent: #42a5f5; }
.doc .note--purple { --note-accent: #b765d6; }
.doc .note--pink   { --note-accent: #ec5a9a; }
.doc .note--red    { --note-accent: #ef5350; }

.doc figure { margin: 1.8rem 0; }
.doc figure img { max-width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 4px; }
.doc figcaption { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.5rem; }

.doc details {
  margin: 0.7rem 0;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper-deep);
}
.doc details > summary { cursor: pointer; font-weight: 500; }
.doc details[open] > summary { margin-bottom: 0.6rem; border-bottom: 1px solid var(--rule); padding-bottom: 0.5rem; }

.doc .formula { font-family: var(--font-mono); font-size: 0.9em; background: var(--paper-deep); padding: 0.1em 0.35em; border-radius: 4px; }
.doc .math { font-family: var(--font-mono); font-size: 0.92rem; background: var(--paper-deep); border: 1px solid var(--rule); padding: 0.8rem 1rem; border-radius: 6px; overflow: auto; }

/* ---- live frame ------------------------------------------------------- */
.live {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--paper);
  display: flex;
  flex-direction: column;
}
.live__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--paper-deep);
}
.live iframe { flex: 1; width: 100%; border: 0; }

/* ---- colophon --------------------------------------------------------- */
.colophon {
  border-top: 1px solid var(--rule);
  padding: 1.4rem var(--gutter) 2.4rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.colophon p { margin: 0; }
.colophon #edited-at::before { content: " · "; }

/* ---- tables, columns, databases, bookmarks, media --------------------- */
.af-table { width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: 0.95rem; }
.af-table th, .af-table td { border: 1px solid var(--rule); padding: 0.5rem 0.75rem; text-align: left; vertical-align: top; }
.af-table th { background: var(--paper-deep); font-weight: 600; }

.af-columns { display: flex; gap: 1.5rem; margin: 1.2rem 0; }
.af-column { flex: 1; min-width: 0; }
@media (max-width: 640px) { .af-columns { flex-direction: column; } }

.af-database, .af-bookmark {
  display: flex; gap: 0.9rem; align-items: flex-start;
  background: var(--paper-deep); border: 1px solid var(--rule); border-radius: 10px;
  padding: 1rem 1.1rem; margin: 1.2rem 0; color: var(--ink); border-bottom: 1px solid var(--rule);
}
.af-database:hover, .af-bookmark:hover { border-color: var(--accent-soft); }
.af-database-icon { font-size: 1.4rem; color: var(--accent); line-height: 1.2; }
.af-database-body, .af-bookmark-body { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.af-database-note, .af-bookmark-desc, .af-bookmark-url { color: var(--ink-soft); font-size: 0.85rem; }
.af-bookmark-url { word-break: break-all; }
.af-bookmark img { width: 120px; height: 80px; object-fit: cover; border-radius: 6px; margin-left: auto; }

.af-media { width: 100%; margin: 1.2rem 0; border-radius: 10px; }
video.af-media { background: #000; }

.mention { background: var(--accent-soft); border-radius: 4px; padding: 0 0.3em; }
mark { color: inherit; border-radius: 3px; padding: 0 0.15em; }

/* ---- motion ----------------------------------------------------------- */
@keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.doc.settling > * { animation: settle 320ms ease both; }

@media (prefers-reduced-motion: reduce) {
  .doc.settling > * { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---- responsive gutters --------------------------------------------- */
@media (max-width: 900px) {
  :root { --gutter: 1.5rem; }
}

@media (max-width: 640px) {
  :root { --gutter: 1.1rem; }
  .masthead__tools { width: 100%; justify-content: space-between; }
  .sheet { padding-top: 2.2rem; }
  .af-columns { gap: 1rem; }
  .af-bookmark img { width: 90px; height: 64px; }
}

@media (max-width: 420px) {
  :root { --gutter: 0.85rem; }
  body { font-size: 1rem; }
  .masthead__tools { gap: 0.45rem; }
  .ghost { padding: 0.28rem 0.6rem; }
  .af-bookmark { flex-direction: column; }
  .af-bookmark img { width: 100%; height: auto; margin-left: 0; }
  .af-row-card { padding: 1.4rem 1.2rem 1.3rem; }
}

@media print {
  .masthead, .live, .colophon { display: none; }
  body { background: #fff; }
  .sheet { max-width: none; padding: 0; }
}

/* ---- AppFlowy database grids ------------------------------------------ */
.af-db { margin: 1.4rem 0; }
.af-db-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.af-db-title { font-weight: 600; color: var(--ink); }
.af-db-open { font-size: 0.85rem; }
.af-db-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: 10px; }
.af-db-table { margin: 0; border-style: hidden; min-width: 100%; }
/* Keep every cell on a single line so all rows share the same height. */
.af-db-table th,
.af-db-table td { white-space: nowrap; }
/* First six columns size to fit their content exactly. */
.af-db-table th:nth-child(-n + 6),
.af-db-table td:nth-child(-n + 6) { width: 1%; }
.af-db-table th { color: var(--ink-soft); font-weight: 500; font-size: 0.85rem; }
/* Tags sit on one line too (no stacking), so tag rows match text rows. */
.af-db-table td .af-tag { margin-bottom: 0; vertical-align: middle; }
.af-db-primary { font-weight: 600; }
.af-db-empty { color: var(--ink-soft); font-style: italic; text-align: center; }
.af-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.05rem; height: 1.05rem; border: 1.5px solid var(--ink-soft); border-radius: 4px;
  font-size: 0.75rem; line-height: 1;
}
.af-check.is-checked { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.af-tag {
  display: inline-block; padding: 0.1rem 0.5rem; margin: 0 0.3rem 0.2rem 0; border-radius: 6px;
  font-size: 0.82rem; background: rgba(255, 255, 255, 0.08); color: var(--ink); border-bottom: none;
}
.af-tag--purple { background: rgba(156, 106, 222, 0.28); }
.af-tag--pink { background: rgba(232, 101, 178, 0.28); }
.af-tag--lightpink { background: rgba(255, 150, 190, 0.24); }
.af-tag--orange { background: rgba(255, 140, 60, 0.28); }
.af-tag--yellow { background: rgba(240, 200, 50, 0.26); }
.af-tag--lime { background: rgba(170, 220, 60, 0.24); }
.af-tag--green { background: rgba(70, 190, 110, 0.26); }
.af-tag--aqua { background: rgba(60, 200, 210, 0.24); }
.af-tag--blue { background: rgba(0, 181, 255, 0.24); }

/* ---- Gallery view (hotels-only cards) --------------------------------- */
.doc details.af-gallery-toggle { margin: 1.4rem 0; }
.doc details.af-gallery-toggle > summary { font-weight: 600; color: var(--ink); }
.af-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.9rem;
  margin-top: 0.3rem;
}
.af-gallery-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.95rem 1rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}
.af-gallery-cover {
  margin: -0.95rem -1rem 0.25rem;
  height: 150px;
  background: var(--paper-deep);
}
.af-gallery-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  border-radius: 0;
}
/* Placeholder cover for rows without an image: the Type tag's emoji,
   centered on the deep-paper band. */
.af-gallery-cover--empty {
  display: flex; align-items: center; justify-content: center;
}
.af-gallery-cover-glyph { font-size: 3rem; line-height: 1; opacity: 0.55; }
.af-gallery-card:hover,
.af-gallery-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  outline: none;
}
/* Field rows clamp to fixed line counts so identical sections take identical
   heights on every card — title gets two lines, the rest a single line. */
/* Scoped under .af-gallery-card so it beats '.doc h4' (margin/font-size),
   which would otherwise leak big heading margins into the cards. */
.af-gallery-title {
  margin: 0; font-size: 1.02rem; line-height: 1.3; color: var(--ink);
  display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden; min-height: 2.6em;
}
/* '.doc p' gives paragraphs a 1.05rem bottom margin; strip it inside cards so
   the fields pack right under the title instead of spreading out. */
.af-gallery-card p { margin: 0; }
/* Single-line rows, tightened; min-height keeps an empty slot the same size
   as a filled one so the same field lands on the same line on every card. */
.af-gallery-where,
.af-gallery-date,
.af-gallery-notes {
  margin: 0; font-size: 0.85rem; line-height: 1.5; min-height: 1.5em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.af-gallery-where { color: var(--ink-soft); }
.af-gallery-date { color: var(--ink); }
.af-gallery-notes { font-style: italic; color: var(--ink-soft); }
.af-gallery-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.45rem; padding-top: 0.6rem; }
/* Both footer rows always render; min-height reserves their space when a
   card has no booking pill or no links, keeping the rows aligned across cards. */
.af-gallery-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; min-height: 1.62rem; }
.af-gallery-meta .af-tag { margin: 0; }
.af-gallery-price { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.af-gallery-links { display: flex; flex-wrap: wrap; gap: 0.75rem; min-height: 1.42rem; }
.af-gallery-links a { font-size: 0.82rem; }

/* ---- Opening a grid row (row detail) ---------------------------------- */
.af-db-row-open { cursor: pointer; transition: background 0.12s ease; }
.af-db-row-open:hover,
.af-db-row-open:focus-visible { background: var(--paper-deep); outline: none; }
.af-db-row-open:focus-visible { box-shadow: inset 2px 0 0 var(--accent); }

.af-row-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 1rem 2rem;
  background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px);
  overflow-y: auto;
}
.af-row-card {
  position: relative; width: min(640px, 100%);
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 1.75rem 1.9rem 1.6rem;
}
.af-row-close {
  position: absolute; top: 0.6rem; right: 0.75rem;
  width: 2rem; height: 2rem; border: none; border-radius: 8px;
  background: transparent; color: var(--ink-soft);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.af-row-close:hover { background: var(--paper-deep); color: var(--ink); }
.af-row-cover {
  margin: -1.75rem -1.9rem 1.1rem;
  height: 200px;
  background: var(--paper-deep);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  overflow: hidden;
}
.af-row-cover img { display: block; width: 100%; height: 100%; object-fit: cover; border: 0; border-radius: 0; }
.af-row-title { margin: 0 2rem 1rem 0; font-size: 1.35rem; line-height: 1.3; }
.af-row-fields { margin: 0; display: grid; grid-template-columns: minmax(6rem, 10rem) 1fr; gap: 0.1rem 1rem; }
.af-row-fields dt {
  color: var(--ink-soft); font-size: 0.85rem; font-weight: 500;
  padding: 0.55rem 0; border-top: 1px solid var(--rule);
}
.af-row-fields dd {
  margin: 0; padding: 0.55rem 0; border-top: 1px solid var(--rule);
  min-width: 0; word-break: break-word;
}
.af-row-fields dt:first-of-type,
.af-row-fields dd:first-of-type { border-top: none; }
.af-row-empty { color: var(--ink-soft); }
.af-row-notes { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.af-row-notes > :first-child { margin-top: 0; }
.af-row-meta { margin: 1.2rem 0 0; color: var(--ink-soft); font-size: 0.8rem; }

@media (max-width: 520px) {
  .af-row-fields { grid-template-columns: 1fr; gap: 0; }
  .af-row-fields dd { padding-top: 0; border-top: none; }
}
