/* Flags of the World (/geography/flags/), owner 2026-12-01 (#158). Builds on the shared style.css (colors, fonts,
   header, fold, footer); only this page's own parts are here. */

/* Wider than the game pages' 480px column: the flags are meant to be big (owner). */
.fw-wrap { max-width: 860px; }
/* A #country link and the A to Z land below the sticky search bar (--fw-tools-h is set by flags.js). */
.fw-row { scroll-margin-top: calc(var(--tb-h, 0px) + var(--fw-tools-h, 100px) + 10px); }
.fw-intro { margin: 0 0 18px; color: var(--text-soft); font: 400 14px/1.55 "Inter", system-ui, sans-serif; text-align: left; }
.fw-intro a { color: var(--accent); font-weight: 600; text-decoration: none; }
.fw-intro a:hover { text-decoration: underline; }

/* ---- color filter ---- */
.fw-fams { display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 6px; margin: 0 0 10px; }
.fw-conts { margin-top: 4px; }   /* the continent filter under the color filter */
/* the label on its own line over the color buttons, all left-aligned like the text above (owner 2026-12-01) */
.fw-fams-label { flex: 0 0 100%; text-align: left; margin-bottom: 2px; font: 700 11px "Inter", system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.fw-fam, .fw-fam-clear {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--panel-edge); background: var(--panel); color: var(--text);
  font: 600 13px "Inter", system-ui, sans-serif; cursor: pointer;
}
.fw-fam:hover, .fw-fam-clear:hover { background: var(--control-hover); }
.fw-fam[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); }
.fw-fam-clear { color: var(--text-dim); }
.fw-fam-clear[hidden] { display: none; }
.fw-sw { display: inline-block; flex: 0 0 auto; width: 14px; height: 14px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.fw-sw-red { background: #d52b1e; }
.fw-sw-orange { background: #ff8200; }
.fw-sw-yellow { background: #ffce00; }
.fw-sw-green { background: #009a44; }
.fw-sw-blue { background: #0052b4; }
.fw-sw-purple { background: #7b2d8b; }
.fw-sw-brown { background: #8f4620; }
.fw-sw-white { background: #ffffff; }
.fw-sw-black { background: #000000; }
.fw-sw-gray { background: #8c8c8c; }

/* ---- search and A to Z, sticky under the topic bar ---- */
.fw-tools {
  position: sticky; top: var(--tb-h, 0px); z-index: 50;
  margin: 0 -8px; padding: 8px 8px 6px;
  background: rgba(0, 0, 0, 0.92);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.fw-search-row { display: flex; align-items: center; gap: 12px; }
.fw-search {
  flex: 1 1 auto; min-width: 0;
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--panel-edge); background: var(--panel); color: var(--text);
  font: 500 16px "Inter", system-ui, sans-serif;   /* 16px: iPhone Safari does not zoom into the field */
}
.fw-search:focus { outline: none; border-color: var(--accent); }
.fw-count { flex: 0 0 auto; color: var(--text-dim); font: 600 13px "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.fw-az { display: flex; justify-content: space-between; margin-top: 6px; }
.fw-az-btn {
  flex: 1 1 0; min-width: 0; padding: 4px 0;
  background: none; border: 0; border-radius: 4px; color: var(--text);
  font: 700 13px "Inter", system-ui, sans-serif; text-align: center;
}
button.fw-az-btn { cursor: pointer; }
button.fw-az-btn:hover { background: var(--control-hover); color: var(--accent); }
span.fw-az-btn, button.fw-az-btn:disabled { color: #444; cursor: default; background: none; }


/* ---- one row per flag: flag (downloads under it) | name and colors ---- */
.fw-list { margin-top: 4px; }
.fw-row {
  --fw-col: 280px;   /* the flag column: the same on every row, so names and colors line up (Nepal too) */
  --fw-w: var(--fw-col);   /* the flag's width; its height follows from --r (width/height, set per row) */
  display: grid;
  /* flag | gap | name over the colors */
  grid-template-columns: var(--fw-col) 24px minmax(0, 1fr);
  grid-template-areas: "flag . name" "flag . colors" "flag . src" "flag . .";
  grid-template-rows: auto auto auto 1fr;
  column-gap: 0;
  padding: 20px 0;
}
.fw-row[hidden] { display: none; }
/* Nepal is taller than wide: a narrower flag so it does not tower over its row. */
.fw-row[data-iso="np"] { --fw-w: 196px; }
.fw-flagcol { grid-area: flag; align-self: start; }
.fw-info { display: contents; }
.fw-flag {
  position: relative; display: block; width: var(--fw-w); aspect-ratio: var(--r); padding: 0; margin: 0; overflow: hidden;
  border: 0; border-radius: 2px; background: var(--tile); cursor: zoom-in;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
  touch-action: pan-y;   /* one finger scrolls the page, two fingers pinch-zoom the flag (flags.js) */
}
.fw-row[data-iso="np"] .fw-flag { box-shadow: none; }
.fw-loaded .fw-flag { background: transparent; }
.fw-flag img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* The zoom hint: "Scroll to zoom" on hover with a mouse, "Pinch to zoom" always shown on touch screens. */
.fw-hint {
  position: absolute; right: 6px; bottom: 6px; display: flex; align-items: center; gap: 5px;
  padding: 5px 7px; border-radius: 8px; background: rgba(0, 0, 0, 0.72); color: #e7e7e7;
  font: 700 12px "Inter", system-ui, sans-serif; opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.fw-hint svg { display: block; flex: 0 0 auto; }
.fw-hint-mouse, .fw-hint-touch { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.fw-hint-touch { display: none; }
.fw-flag:hover .fw-hint, .fw-flag:focus-visible .fw-hint { opacity: 1; }
/* touch screens: no hover, so the hint is always shown, and it says pinch */
@media (hover: none) {
  .fw-hint { opacity: 0.9; padding: 3px 6px; font-size: 10px; right: 4px; bottom: 4px; }
  .fw-hint-mouse { display: none; }
  .fw-hint-touch { display: flex; gap: 4px; }
  .fw-hint svg { width: 11px; height: 11px; }
}

/* Downloads under the flag: one quiet line, the three formats as small pills. */
.fw-dl { display: flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--text-dim); }
.fw-dl-icon { flex: 0 0 auto; margin-right: 2px; }
.fw-dl button {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--panel-edge); background: var(--panel);
  color: var(--text-soft); font: 700 11px "Inter", system-ui, sans-serif; letter-spacing: 0.06em; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.fw-dl button:hover, .fw-dl button[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-wash); }
.fw-dl { position: relative; flex-wrap: wrap; }
/* the size menu of PNG and JPG */
.fw-size {
  position: absolute; z-index: 60; top: calc(100% + 6px); display: flex; gap: 4px; padding: 5px;
  border: 1px solid var(--panel-edge); border-radius: 12px; background: #111; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.fw-size[hidden] { display: none; }
.fw-dl .fw-size button { border-radius: 8px; padding: 5px 9px; font-variant-numeric: tabular-nums; letter-spacing: 0; white-space: nowrap; }

.fw-sw-other { background: repeating-linear-gradient(45deg, #555 0 2px, #2a2a2a 2px 4px); }

/* name, and the aspect ratio small beside it (owner 2026-12-01) */
.fw-head { grid-area: name; display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; min-width: 0; }
.fw-ratio { flex: 0 0 auto; color: var(--text-dim); font: 600 12px "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums; }   /* plain text, no pill (owner 2026-12-01) */
/* where the colors come from: under the colors, moved down by flags.js to the height of the download line */
.fw-src { grid-area: src; margin: 10px 0 0; color: var(--text-dim); font: 500 12px "Inter", system-ui, sans-serif; }
.fw-src a { color: var(--text-soft); }
.fw-src a:hover { color: var(--accent); }
.fw-pd { margin-left: 4px; font: 500 11px "Inter", system-ui, sans-serif; color: var(--text-dim); }
.fw-name { margin: 0; font: 400 28px/1.1 "Anton", Impact, sans-serif; letter-spacing: 0.01em; color: var(--text); text-transform: uppercase; }
.fw-colors { grid-area: colors; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
/* One color: swatch, "Red · Crimson", hex and RGB (each copied with a click), share of the flag at the end. */
.fw-color {
  /* the name column: the longest name plus 20px to the hex (--fw-name-w measured by flags.js; 164px until then) */
  display: grid; grid-template-columns: 18px var(--fw-name-w, 164px) auto; grid-template-areas: "sw name vals";
  align-items: center; column-gap: 6px; font: 500 13px "Inter", system-ui, sans-serif; color: var(--text);
}
.fw-color .fw-sw { grid-area: sw; width: 18px; height: 18px; }
.fw-cname { grid-area: name; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fw-dot { color: var(--text-dim); }
.fw-vals { grid-area: vals; display: flex; margin-left: -6px; }   /* the button's padding: the hex text starts on the column */
/* the hex button has a fixed width, so every RGB value starts at the same x (owner 2026-12-01) */
.fw-vals .fw-copy:first-child { width: 98px; flex: 0 0 auto; }
/* name white, then a gray dot and the share in gray (owner 2026-12-01) */
.fw-pct { color: var(--text-soft); font-weight: 500; font-variant-numeric: tabular-nums; }
.fw-copy {
  position: relative; display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px; border-radius: 6px;
  border: 0; background: none; color: var(--text-soft);   /* hex gray like the RGB; only the color name is white (owner 2026-12-01) */ text-align: left;
  font: 500 13px "Inter", system-ui, sans-serif; font-variant-numeric: tabular-nums; cursor: copy; white-space: nowrap;
}
.fw-copy:hover { background: var(--control-hover); }
.fw-rgb { color: var(--text-soft); }
.fw-copy-icon { opacity: 0; transition: opacity 0.15s; }
.fw-copy:hover .fw-copy-icon, .fw-copy:focus-visible .fw-copy-icon { opacity: 0.8; }
.fw-copy.fw-copied::after {
  content: "Copied"; position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%);
  padding: 3px 7px; border-radius: 6px; background: var(--accent); color: var(--on-accent);
  font: 700 11px "Inter", system-ui, sans-serif; pointer-events: none;
}
.fw-empty { margin: 30px 0; text-align: center; color: var(--text-dim); font: 500 14px "Inter", system-ui, sans-serif; }

/* Phones: flag and name on top; the colors below across the whole width. The row is the container, so the flag
   width is a share of the row: 46cqw. Each color takes two lines: name and share,
   then hex and RGB. */
@media (max-width: 560px) {
  .fw-row {
    container-type: inline-size;
    /* name and ratio on top, the flag across the full width under it, then downloads, colors, source (owner 2026-12-01) */
    --fw-col: 100cqw;
    --fw-w: var(--fw-col);
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "name" "flag" "colors" "src";
    grid-template-rows: auto auto auto auto;
    padding: 16px 0;
  }
  .fw-row[data-iso="np"] { --fw-w: 60cqw; }   /* taller than wide: not the full width */
  .fw-name { font-size: 21px; }
  .fw-colors { margin-top: 12px; gap: 8px; }
  .fw-color { grid-template-columns: 18px minmax(0, 1fr); grid-template-areas: "sw name" ". vals"; row-gap: 1px; }
  .fw-head { flex-wrap: wrap; gap: 4px 8px; margin-bottom: 6px; }
  .fw-vals { margin-left: -4px; }
  .fw-vals .fw-copy:first-child { width: 88px; }
  .fw-copy { font-size: 12.5px; padding: 2px 4px; }
  .fw-copy-icon { opacity: 0.5; }   /* no hover on a phone: the icon says a tap copies */
  .fw-dl { gap: 4px; margin-top: 8px; }
  .fw-dl button { padding: 3px 7px; font-size: 10px; }
  .fw-intro { font-size: 13px; }
  .fw-az-btn { font-size: 11.5px; }
  .fw-search-row { gap: 8px; }
}

/* ---- the zoom lens and its color label (mouse only) ---- */
.fw-lens {
  position: fixed; z-index: 150; width: 180px; height: 180px; border-radius: 50%; overflow: hidden;
  border: 2px solid var(--text); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6); pointer-events: none;
}
.fw-lens canvas { display: block; width: 100%; height: 100%; }
.fw-lens::after {   /* the exact point being read */
  content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -5px 0 0 -5px;
  border: 1px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #000;
}
.fw-lens[hidden], .fw-tip[hidden] { display: none; }
.fw-tip {
  position: fixed; z-index: 151; display: flex; align-items: center; gap: 8px;
  padding: 7px 11px; border-radius: 8px; background: #111; border: 1px solid var(--panel-edge);
  color: var(--text); font: 600 13px "Inter", system-ui, sans-serif; white-space: pre; pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* ---- the large view: just the flag, bigger ---- */
html.fw-modal-open { overflow: hidden; }
.fw-modal { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; background: var(--bg); }
.fw-modal[hidden] { display: none; }
.fw-modal-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 4px; }
.fw-modal-name { margin: 0; font: 400 26px/1.1 "Anton", Impact, sans-serif; text-transform: uppercase; color: var(--text); }
.fw-modal-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--control); color: var(--text); font: 400 26px/1 "Inter", system-ui, sans-serif; cursor: pointer; }
.fw-modal-close:hover { background: var(--control-hover); }
.fw-stage { position: relative; flex: 1 1 auto; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.fw-stage.fw-dragging { cursor: grabbing; }
.fw-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; }
