/* ============================================================
   lang.css: the language button at the end of the nav (js/lang.js).
   His pick, 30 October 2026 (codex LANG3): "I like the design of the one
   which is the name tag, especially with the UI… if it sat where the
   button of the quiet link sits at, it would be a better one."

   The name tag's button and short list (lang-lab variants 5 and 7), kept
   as they were, under the site's own names. It is the nav's own cream
   glass, never gold, so "Say hi" stays the one call to action (codex A1).

   Desktop: the last thing in the capsule, after "Say hi", 8px from it;
     the capsule's own end padding is the gap on its right (15px since
     30 October 2026, the same as the space above and below it).
   Phone: in the capsule between "where you are" and the chevron, one
     more column in the capsule's grid.
   The list is mounted on <body>, fixed under the capsule, in the nav's
   lacquer, with a gold point on the current language as the nav has on
   the current page. System CJK faces only; nothing is fetched.
   ============================================================ */

:root {
  --lang-ink: #F7EFE4;
  --lang-ink-2: rgba(247, 239, 228, 0.68);
  --lang-acc: #D4A853;
  --lang-hover: rgba(247, 239, 228, 0.08);
}
html[data-field="light"] {
  --lang-ink: #35191E;
  --lang-ink-2: #5E4548;
  --lang-acc: #7A5518;
  --lang-hover: rgba(53, 25, 30, 0.06);
}

/* ---------------- the button ---------------- */
.langtag {
  flex: none;
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px 0 11px; margin: 0 0 0 8px; border-radius: 999px;
  font: 600 0.74rem/1 var(--font-ui); letter-spacing: 0.08em; color: var(--fg-2, var(--lang-ink-2)); white-space: nowrap;
  background: linear-gradient(165deg, rgba(255, 236, 212, 0.17), rgba(255, 236, 212, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 236, 212, 0.22), inset 0 0 0 1px rgba(247, 239, 228, 0.12), 0 2px 5px -2px rgba(0, 0, 0, 0.35);
  transition: color 350ms var(--ease-ui, ease), background-color 350ms var(--ease-ui, ease), transform 520ms cubic-bezier(0.34, 1.36, 0.5, 1);
  text-shadow: none;
}
html[data-field="light"] .langtag { background: linear-gradient(165deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4)); box-shadow: inset 0 1px 0 #fff, inset 0 0 0 1px rgba(53, 25, 30, 0.1), 0 2px 5px -3px rgba(53, 25, 30, 0.3); }
.langtag:focus-visible { outline: 2px solid var(--lang-acc); outline-offset: 3px; }
.langtag__c svg { display: block; width: 10px; height: 10px; transition: transform 450ms var(--ease-grace, ease); }
.langtag.is-open .langtag__c svg { transform: rotate(180deg); }
.langtag:hover, .langtag.is-open { color: var(--fg, var(--lang-ink)); }
.langtag:active { transform: scale(0.96); }

/* each language is set in its own script's system face (the button and the list carry lang) */
.langtag [lang="zh-Hans"], .langtag[lang="zh-Hans"], .langtag__menu [lang="zh-Hans"] {
  font-family: "Gloock", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
.langtag [lang="ko"], .langtag[lang="ko"], .langtag__menu [lang="ko"] {
  font-family: "Gloock", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", sans-serif;
}
.langtag [lang="zh-Hans"], .langtag [lang="ko"], .langtag__t[lang="zh-Hans"], .langtag__t[lang="ko"] { font-size: 0.86rem; letter-spacing: 0.02em; }

/* ---------------- the list: on <body>, fixed, placed by lang.js and clamped on screen ---------------- */
.langtag__menu {
  position: fixed; z-index: 60; top: 0; left: 0; width: 190px; max-width: calc(100vw - 20px); padding: 8px;
  isolation: isolate; border-radius: 24px; -webkit-backdrop-filter: blur(16px) saturate(1.5); backdrop-filter: blur(16px) saturate(1.5);
  visibility: hidden; opacity: 0; pointer-events: none;
  transform: translateY(-8px) scale(0.97); transform-origin: var(--langtag-ox, 100%) 0;
  color: var(--lang-ink);
  transition: opacity 240ms var(--ease-ui, ease), transform 480ms cubic-bezier(0.34, 1.26, 0.5, 1), visibility 0s linear 480ms;
}
.langtag__menu[data-open="true"] { visibility: visible; opacity: 1; pointer-events: auto; transform: none; transition-delay: 0s; }
.langtag__menu ul { list-style: none; margin: 0; padding: 0; }

/* the nav's own three lacquers (.mat, base.css), a touch thicker because words sit over the page */
.langtag__menu .mat { border-radius: inherit; }
html:not([data-field="light"]) .langtag__menu .mat--dark {
  background: radial-gradient(120% 60% at 10% 0%, rgba(255, 220, 182, 0.14), rgba(255, 220, 182, 0) 58%), linear-gradient(180deg, rgba(96, 44, 52, 0.9) 0%, rgba(58, 24, 30, 0.93) 100%);
}
html[data-field="blue"] .langtag__menu .mat--blue {
  background: radial-gradient(120% 60% at 10% 0%, rgba(200, 220, 255, 0.14), rgba(200, 220, 255, 0) 58%), linear-gradient(180deg, rgba(40, 62, 128, 0.92) 0%, rgba(20, 36, 88, 0.94) 100%);
}

.langtag__opt {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%;
  min-height: 42px; padding: 0 12px; border-radius: 14px; text-align: left;
  font: 400 1.12rem/1.1 var(--font-text); color: var(--lang-ink); cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color 300ms var(--ease-ui, ease), color 300ms var(--ease-ui, ease);
}
.langtag__opt:focus-visible { outline: 2px solid var(--lang-acc); outline-offset: -2px; }
.langtag__opt[aria-current="true"]::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--lang-acc); flex: none; }
@media (hover: hover) and (pointer: fine) { .langtag__opt:hover { background: var(--lang-hover); } }

/* ---------------- desktop: the space after the button ----------------
   30 October 2026: the button is 28px tall in a 58px capsule, so it has 15px above and below, but the capsule's end
   padding (9px, made for the 40px "Say hi" button) left only 9px after it. 15px makes the three equal. Nothing else moves:
   the links sit from the capsule's left edge, so the bubble's place is the same. */
@media (min-width: 960px) {
  .pill.has-langtag { padding-right: 15px; }
}

/* ---------------- the phone capsule makes room for one more control ----------------
   nav.js's capsule is a grid "id here toggle" over "links". The button is one more column, between "where you are"
   and the chevron.
   30 October 2026: his name never wraps. The name's column used to be allowed down to the width of the word "Lawrence"
   (a floor of 126px), so "Kamau" dropped under it whenever "where you are" asked for room. Now the column is never
   narrower than the name on one line, and "where you are" takes only what is left, shortened with an ellipsis. */
@media (max-width: 959px) {
  .pill.has-langtag { grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) auto auto; grid-template-areas: "id here lang toggle" "links links links links"; }
  .pill.has-langtag .homelink__name { white-space: nowrap; }
  .pill.has-langtag .langtag { grid-area: lang; margin: 0 2px 0 4px; }
}

/* 30 October 2026: under 408px the room left for "where you are" is under five letters (three Chinese characters), which
   would only read as "Ab…", so it gives way entirely: the name, the button and the chevron stay, and the room's name
   returns from 408px up. (The same rule keeps its padding from pushing into the button.) */
@media (max-width: 407px) {
  .pill.has-langtag .pill__here { display: none; }
}

/* 30 October 2026: at 320px the capsule holds 282px, and his name, the button and the chevron need 282 in English and
   292 in Chinese ("中文" is wider than "EN"). The name's own spare gaps give back what is needed: the 8px after it, 2px
   of the gap after his mark, and the 2px beside the chevron. Nothing the eye reads as a shape moves. */
@media (max-width: 339px) {
  .pill.has-langtag .pill__id { padding-right: 0; gap: 8px; }
  .pill.has-langtag .langtag { margin-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .langtag, .langtag__c svg { transition-duration: 1ms !important; transition-delay: 0s !important; }
  .langtag__menu { transition: opacity 160ms linear, visibility 0s linear 160ms; transform: none; }
  .langtag__menu[data-open="true"] { transition-delay: 0s; }
}
