:root {
  --accent: #9f2f28;
  --bg: #f4efe4;
  --fg: #111;
  --muted: #555;
  --rule: rgba(0, 0, 0, 0.16);
  --rule-soft: rgba(0, 0, 0, 0.12);
  --max: 980px;
  --map-land: #e2dac6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #c45a52;
    --bg: #1b1b1b;
    --fg: #f2efe7;
    --muted: #b6afa3;
    --rule: rgba(255, 255, 255, 0.16);
    --rule-soft: rgba(255, 255, 255, 0.12);
    --map-land: #333;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 110%;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  max-width: var(--max);
  margin: 0 auto;
  padding: 36px 40px 28px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.masthead { margin-bottom: 28px; }

.name {
  font-family: "Spectral", Georgia, serif;
  font-size: 4.1rem;
  line-height: 0.92;
  font-weight: 500;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
}

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

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

main { flex: 1; }

main h1 {
  font-family: "Spectral", Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}

main h2 {
  font-family: "Spectral", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem;
  padding-top: 4rem;
  width: fit-content;
}

main h3 { margin: 4rem 0 0.5rem; }
main h2 + h3 { margin-top: 0.8rem; }

main h2::after {
  content: "";
  display: block;
  height: 2px;
  background: var(--accent);
  margin-top: 0.5rem;
}

.heading-anchor {
  position: absolute;
  margin-left: -1em;
  padding-right: 0.25em;
  color: var(--muted, #999);
  opacity: 0;
  text-decoration: none;
  transition: opacity 0.15s;
}
:is(h2, h3, h4):hover .heading-anchor,
.heading-anchor:focus { opacity: 1; }

.intro {
  font-family: "Spectral", Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0 0 32px;
  max-width: 60ch;
}

.cp-link { color: inherit; text-decoration: none; display: block; }
.cp-link:hover, .cp-link:focus { text-decoration: none; }
.cp-link:hover .cp-text { color: var(--accent); }
.intro { display: block; }
.intro .cp-text { font-style: italic; display: block; transition: color 0.15s ease; }
.intro .cp-attr { color: var(--muted); font-size: 0.92em; font-style: normal; display: block; text-align: right; margin-top: 6px; }

.commonplace-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  gap: 24px;
}
.cp-card {
  background: #1b1b1b;
  color: #f2efe7;
  padding: 32px 36px 24px;
  display: flex;
  align-items: flex-start;
  gap: 28px;
}
.cp-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.cp-thumb-link {
  flex: 0 0 auto;
  display: none;
  width: 140px;
  align-self: flex-start;
  margin-top: 4px;
  transition: opacity 0.15s ease;
}
.cp-thumb-link:hover { opacity: 0.82; }
.cp-card .cp-text {
  font-family: "Spectral", Georgia, serif;
  font-style: italic;
  font-size: 1.3rem;
  line-height: 1.45;
  margin: 0;
  color: inherit;
}
.cp-quote {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cp-card .cp-text-tr {
  font-family: "Spectral", Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.45;
  margin: 0;
  color: rgba(242, 239, 231, 0.78);
}
.cp-card .cp-attr {
  margin: 0;
  padding: 0;
  border: none;
  display: block;
  text-align: right;
  font-size: 0.95rem;
  color: rgba(242, 239, 231, 0.72);
  font-style: normal;
}
.cp-card .cp-src { font-style: italic; }
.cp-portrait {
  display: block;
  width: 100%;
  height: auto;
  filter: grayscale(0.1);
}
.cp-notes {
  margin-top: 0;
  padding-top: 18px;
  border-top: 1px solid rgba(242, 239, 231, 0.15);
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 0.88rem;
  line-height: 1.55;
  color: rgba(242, 239, 231, 0.72);
}
.cp-notes p { margin: 0 0 14px; }
.cp-notes p:last-child { margin: 0; }
.cp-notes strong { color: rgba(242, 239, 231, 0.95); font-weight: 500; }
@media (max-width: 720px) {
  .cp-card { padding: 24px; flex-direction: column; }
  .cp-thumb-link { width: 120px; align-self: flex-end; }
}

.home-intro {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.4rem;
}
.home-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
}
.home-list li { font-size: 0.95rem; padding: 2px 0; }
.home-period { color: var(--muted); font-size: 0.85rem; margin-left: 6px; }

.travel-map {
  height: 506px;
  width: 100%;
  margin: 1.5rem 0 0.5rem;
  border: 1px solid var(--rule);
  background: var(--map-land);
}
.travel-map .leaflet-container { font: inherit; }
.map-credit {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.4rem 0 1.25rem;
}
.travel-stats {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  padding: 0;
  margin: 1.5rem 0 0.75rem;
}
.travel-stats li {
  font-size: 0.85rem;
  color: var(--muted);
}
.travel-stats strong {
  display: block;
  font-family: "Spectral", Georgia, serif;
  font-size: 1.9rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.1;
}
.flag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 1rem;
}
.flag-row .flag { margin: 0; }
.flag-unvisited { filter: grayscale(1); opacity: 0.3; }

/* Visited-countries filter: a strict grid so flag edges line up in columns. */
.flag-filter {
  display: grid;
  grid-template-columns: repeat(auto-fill, 22px);
  gap: 6px;
  justify-content: start;
}
.flag-btn {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  line-height: 0;
  border-radius: 2px;
}
.flag-btn .flag { display: block; margin: 0; }
.flag-btn[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 1px; }
.flag-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.flag-filter.filtering .flag-btn[aria-pressed="false"] { opacity: 0.32; }
.filter-clear {
  font: inherit;
  font-size: 0.8rem;
  margin: 10px 0 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}
.extreme-tip {
  font-size: 0.7rem;
  text-align: center;
  line-height: 1.3;
}
.travel[hidden] { display: none; }
.filter-title { margin-top: 1.6rem; }
/* Five region columns share one row; equal-width, labels wrap, fonts shrink
   so all five panels fit the content width. */
.region-col { min-width: 0; }
.region-col .region-title { font-size: 1.25rem; margin-bottom: 0.5rem; }
.region-col .flag-label { font-size: 0.75rem; letter-spacing: 0.02em; }
.region-col .flag-row { margin-bottom: 0.6rem; }
.travel-extremes {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}
.flag-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.region-cols {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0 14px;
  margin: 0 0 1.5rem;
}
@media (max-width: 860px) {
  .region-cols { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 560px) {
  .region-cols { grid-template-columns: 1fr; }
}
.region-title {
  font-family: "Spectral", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 500;
  margin: 0.25rem 0 0.6rem;
}

.travel-fold {
  margin: 0 0 0.75rem;
  border-bottom: 1px solid var(--rule-soft);
}
.travel-fold > summary {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  cursor: pointer;
  padding: 0.5rem 0;
  list-style-position: inside;
}
.travel-fold > summary:hover { color: var(--accent); }
.travel-fold[open] > summary { margin-bottom: 0.75rem; }
.travel-fold .flag-row,
.travel-fold .travel-extremes,
.travel-fold .badge-legend { margin-bottom: 0.75rem; }

.travel-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  border-top: 1px solid var(--rule);
}
.travel {
  padding: 12px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.travel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}
.travel-place { font-size: 0.98rem; }
.flag {
  width: 22px;
  height: 17px;
  margin-right: 7px;
  vertical-align: -2px;
  border: 1px solid var(--rule-soft);
  object-fit: cover;
}
.flag + .flag { margin-left: -3px; }
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: middle;
  text-decoration: none;
}
.tag:hover {
  text-decoration: none;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.tag-cat { padding: 2px; }
.tag-cat::before {
  content: "";
  width: 15px;
  height: 15px;
  background-color: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}
.tag-ancient { --glyph: url(/assets/img/icons/column.svg); }
.tag-historical { --glyph: url(/assets/img/icons/castle.svg); }
.tag-museum { --glyph: url(/assets/img/icons/landmark.svg); }
.tag-worship { --glyph: url(/assets/img/icons/cross.svg); }
.tag-worship-orthodox { --glyph: url(/assets/img/icons/cross-orthodox.svg); }
.tag-worship-crescent { --glyph: url(/assets/img/icons/crescent.svg); }
.tag-worship-wheel { --glyph: url(/assets/img/icons/dharma-wheel.svg); }
.tag-nature { --glyph: url(/assets/img/icons/tree.svg); }
.tag-unesco {
  margin: 0 0 0 4px;
  padding: 0 3px;
  font-size: 0.47rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  vertical-align: super;
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.tag-unesco:hover { background: var(--accent); }
.tag-tentative { opacity: 0.55; }

.place-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 2px;
}
.place-link:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.place-local { color: var(--muted); font-style: italic; }
.badge-note {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.travel-map:fullscreen { height: 100%; }
.fs-btn::before {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  margin: 7px auto;
  background-color: #333;
  -webkit-mask: url(/assets/img/icons/maximize.svg) center / contain no-repeat;
  mask: url(/assets/img/icons/maximize.svg) center / contain no-repeat;
}

/* Larger tap targets on touch devices (iOS ~44px / Android ~48px guidance). */
@media (pointer: coarse) {
  .fs-btn { width: 44px; height: 44px; }
  .fs-btn::before { margin: 14px auto; }
}

.badge-legend {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 4px 28px;
  padding: 0;
  margin: 1.25rem 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.badge-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.legend-count {
  margin-left: auto;
  font-family: "Spectral", Georgia, serif;
  font-size: 1.05em;
  color: var(--accent);
}
.badge-legend .legend-break { grid-column: 1; }
.legend-glyphs { display: inline-flex; align-items: center; }
.travel-date {
  flex: 0 0 auto;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.place-list {
  margin: 8px 0 0;
  padding-left: 1.1rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  max-width: 64ch;
}
.place-list li { padding: 1px 0; }

.home {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 42px;
}

.home .section {
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}

.home .section h2 { margin: 0 0 8px; padding-top: 0; }
.home .section h2::after { content: none; }

.home .section p {
  margin: 0;
  line-height: 1.6;
  font-size: 0.95rem;
  max-width: 52ch;
}

.home .sidebar { padding-top: 2px; }

.home .sidebar h2 { margin: 0 0 8px; }

.work-list {
  border-top: 1px solid var(--rule);
  margin-top: 12px;
}

.work {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule-soft);
  align-items: baseline;
}

.work-title { font-size: 0.95rem; line-height: 1.45; }
.work-year { font-size: 0.82rem; opacity: 0.78; letter-spacing: 0.04em; }

footer {
  margin-top: 36px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}

footer .footer-links { display: flex; gap: 18px; }

@media (max-width: 760px) {
  body { padding: 24px 20px; }
  .name { font-size: 3rem; }
  .home { grid-template-columns: 1fr; gap: 24px; }
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.gallery a {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.06);
}

.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.gallery a:hover img { transform: scale(1.04); }

@media (prefers-color-scheme: dark) {
  .gallery a { background: rgba(255, 255, 255, 0.06); }
}

.float {
  float: left;
  margin: 0.35rem 1.6rem 2rem 0;
}

main ul { display: flow-root; }

.float ~ ul {
  list-style-position: inside;
  padding-left: 0;
}

.float img,
img.float { display: block; height: auto; max-width: 100%; }

.project-icon { border-radius: 20px; }

main h2,
main h3 { clear: both; }

@media (max-width: 760px) {
  .float { float: none; margin: 0.5rem 0 1rem; }
}

.project-head {
  display: flex;
  gap: 1.6rem;
  align-items: flex-start;
  margin: 2.5rem 0 0;
}
.project-head > a { flex: 0 0 auto; display: block; }
.project-head .project-icon {
  width: 120px;
  height: 120px;
  display: block;
}
.project-head > div { flex: 1 1 auto; min-width: 0; }
.project-head > div > :first-child { margin-top: 0; }
.project-head > div > :last-child { margin-bottom: 0; }
.project-head h2 { margin-bottom: 0.4rem; }
.project-head + p { margin-top: 0.85rem; }
@media (max-width: 760px) {
  .project-head { flex-direction: column; gap: 0.75rem; }
}

.carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  border-radius: 4px;
  margin: 1.25rem 0;
  scrollbar-width: none;
}

.carousel::-webkit-scrollbar { display: none; }

.carousel > a {
  flex: 0 0 100%;
  scroll-snap-align: center;
}

.carousel img {
  width: 100%;
  height: auto;
  display: block;
}

.carousel-wrap { position: relative; }
.carousel-wrap:not(.float) { margin: 1.25rem 0; }
.carousel-wrap .carousel { margin: 0; }

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-btn:hover { background: rgba(0, 0, 0, 0.78); }
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }

.project-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0.6rem 0 0.4rem;
}
.project-badges a { display: inline-block; line-height: 0; }
.project-badges img { height: 40px; width: auto; display: block; }
.project-badges .gh-badge {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  background: #181717;
  text-decoration: none;
  box-sizing: border-box;
}
.project-badges .gh-badge img { height: 22px; width: auto; display: block; }
.project-badges .gh-badge:hover { text-decoration: none; }

.project-badges .notes-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  background: #2684FF;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  box-sizing: border-box;
}
.project-badges .notes-badge::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background-color: #fff;
  -webkit-mask: url('/assets/img/tech/confluence.svg') center/contain no-repeat;
          mask: url('/assets/img/tech/confluence.svg') center/contain no-repeat;
}
.project-badges .notes-badge:hover { text-decoration: none; }

.project-badges .notes-badge--disabled {
  background: #DEEBFF;
  color: #97A0AF;
  cursor: default;
  pointer-events: none;
}
.project-badges .notes-badge--disabled::before {
  background-color: #97A0AF;
}
@media (prefers-color-scheme: dark) {
  .project-badges .notes-badge--disabled {
    background: #253858;
    color: #6B778C;
  }
  .project-badges .notes-badge--disabled::before {
    background-color: #6B778C;
  }
}

.stack {
  display: grid;
  grid-template-columns: repeat(auto-fill, 54px);
  gap: 5px;
  margin: 1rem 0;
}

.chip {
  --brand: #888;
  display: flex;
  flex-direction: column;
  width: 54px;
  min-height: 67px;
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--rule));
  border-radius: 4px;
  overflow: hidden;
  background: color-mix(in srgb, var(--brand) 7%, var(--bg));
  font-size: 9px;
  line-height: 1.2;
}

.chip .ico {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.chip .ico img { max-width: 20px; max-height: 20px; display: block; }

.chip .label {
  background: color-mix(in srgb, var(--brand) 14%, var(--bg));
  text-align: center;
  padding: 3px 2px;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

@media (prefers-color-scheme: dark) {
  .chip {
    background: color-mix(in srgb, var(--brand) 18%, var(--bg));
    border-color: color-mix(in srgb, var(--brand) 35%, var(--rule));
  }
  .chip .label {
    background: color-mix(in srgb, var(--brand) 28%, var(--bg));
  }
}
