/* EU5 advances screen (sections/advances.mjs, src/advances-tree.js, src/advances.js, docs/advances.md).
   The game's own pictures from gfx/interface (scripts/advances.mjs -> img/advscreen/): the node frame with its four
   states, the round backgrounds, the pictures of what an advance unlocks, the age paintings. Colours are the game's
   flat colour textures (gfx/interface/colors), passed in by the page as --c-* (fallbacks are the same values).
   Node coordinates follow technology_lateralview.gui: a 330 x 265 widget, the 270 x 270 frame at its bottom, the
   250 x 200 card inside it, the 113 px icon at the top. */
.ascr { --c-low-green: #2b3431; --c-dark-purple: #3b223b; --c-bronze: #3e2e15; --c-greyish: #2e2c26; --c-paper: #473c31; --c-dark-blue: #0a0e18; --c-intense-bg-blue: #1a222e; --c-new-gold: #7d6339; --c-bg-brown: #3b3023; --c-mid-green: #1d3820;
  margin: 18px 0 8px; background: var(--c-dark-blue); border: 1px solid #3b3424; border-radius: 6px; overflow: hidden; color: #e8dcc0; }
.ascr img { max-width: none; }

/* tabs: one per age, as on the game's research screen */
.ascr-tabs { display: flex; overflow-x: auto; scrollbar-width: none; background: linear-gradient(#18202b, #0c1118); }
.ascr-tabs::-webkit-scrollbar { display: none; }
.ascr-tabs a { flex: 1 0 auto; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; color: #a99d80; text-decoration: none; font: 400 17px/1.1 var(--display); white-space: nowrap; }
.ascr-tabs a img { width: 26px; height: 26px; }
.ascr-tabs a:hover { color: #f2e6c6; background: rgba(255, 255, 255, .04); }
.ascr-tabs a[aria-current] { color: #fff; background: linear-gradient(#3a3020, #241d12); box-shadow: inset 0 0 0 1px #7d6339; }

/* the head: the age's painting, the age, its three institutions */
.ascr-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 22px; min-height: 112px; padding: 16px 18px;
  background: linear-gradient(90deg, rgba(10, 14, 24, .94) 0%, rgba(10, 14, 24, .62) 52%, rgba(10, 14, 24, .25) 100%), var(--art, none) center 38% / cover no-repeat; }
.ascr-age { display: flex; align-items: center; gap: 12px; }
.ascr-age img { width: 44px; height: 44px; filter: drop-shadow(0 2px 3px #000); }
.ascr-age b { display: block; font: 400 27px/1.1 var(--display); color: #fff; text-shadow: 0 2px 6px #000; }
.ascr-age span { color: #d8ccab; text-shadow: 0 1px 3px #000; }
.ascr-inst { display: flex; flex-wrap: wrap; gap: 8px; }
.ascr-inst a { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; background: rgba(28, 24, 17, .82); border: 1px solid #6b5a35; border-radius: 4px; color: #eadfc4; text-decoration: none; line-height: 1.15; }
.ascr-inst a:hover { border-color: #c9a650; }
.ascr-inst img { width: 32px; height: 32px; }
.ascr-inst small { display: block; color: #b2a684; }

/* the bar: country, focus, find, zoom */
.ascr-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; background: #111720; border-top: 1px solid #262d36; border-bottom: 1px solid #262d36; }
.ascr-bar input { height: 38px; padding: 0 11px; background: #0a0e14; color: #eadfc4; border: 1px solid #4b4430; border-radius: 4px; font: inherit; font-size: 15px; }
.ascr-bar input:focus { outline: none; border-color: #c9a650; }
.ascr-country { position: relative; flex: 1 1 210px; max-width: 320px; }
.ascr-country input { width: 100%; }
.ascr-cl { position: absolute; z-index: 30; top: 42px; left: 0; width: min(360px, 88vw); max-height: 330px; overflow: auto; background: #141a22; border: 1px solid #4b4430; border-radius: 4px; box-shadow: 0 12px 30px rgba(0, 0, 0, .55); }
.ascr-cl button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; background: none; border: 0; color: #eadfc4; font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
.ascr-cl button:hover, .ascr-cl button:focus { background: #232b36; }
.ascr-cl button img, .ascr-cl button i { flex: none; width: 27px; height: 18px; border-radius: 2px; }
.ascr-cl button span { flex: 1; }
.ascr-cl p { margin: 0; padding: 10px; color: #a99d80; }
.ascr-focus { display: flex; gap: 6px; }
.ascr-focus[hidden] { display: none; }
.ascr-focus button { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 11px 0 6px; background: #0a0e14; color: #cfc4a6; border: 1px solid #4b4430; border-radius: 4px; font: inherit; font-size: 14px; cursor: pointer; }
.ascr-focus button img { width: 26px; height: 26px; }
.ascr-focus .fs { display: none; }
.ascr-focus button:hover { border-color: #8a7448; color: #fff; }
.ascr-focus button[aria-pressed="true"] { background: #3a2e16; color: #fff; border-color: #c9a650; }
.ascr-find { flex: 0 1 200px; min-width: 120px; }
.ascr-find.none { border-color: #a1453a !important; }
.ascr-zoom { display: flex; gap: 4px; margin-left: auto; }
.ascr-zoom button { min-width: 38px; height: 38px; padding: 0 8px; background: #0a0e14; color: #eadfc4; border: 1px solid #4b4430; border-radius: 4px; font: 600 17px/1 var(--body); cursor: pointer; }
.ascr-zoom button:hover { border-color: #c9a650; }

/* the screen and the panel beside it */
.ascr-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.ascr-view { position: relative; height: min(76vh, 880px); overflow: hidden; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; outline: none;
  background: radial-gradient(ellipse at 40% 0%, rgba(46, 64, 86, .55), transparent 70%), var(--c-intense-bg-blue); }
.ascr-view::before { content: ""; position: absolute; right: 0; bottom: 0; width: 78%; aspect-ratio: 1080 / 440; background: url(img/advscreen/bg-researches.webp) right bottom / contain no-repeat; opacity: .13; pointer-events: none; }
.ascr-view:focus-visible { box-shadow: inset 0 0 0 2px #c9a650; }
.ascr-view.drag { cursor: grabbing; }
.ascr-view.drag .an { pointer-events: none; }
.ascr-c { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; transform: translate(24px, 0) scale(.62); }
.ascr-c.glide { transition: transform .3s ease; }
.ascr-panel { height: min(76vh, 880px); overflow: auto; padding: 12px 16px 16px; background: #131920; border-left: 1px solid #262d36; font-size: .95rem; line-height: 1.5; }
.ascr-hint { color: #a99d80; }
.ascr-note { margin: 0; padding: 9px 14px; color: #b9ad8f; font-size: .9rem; background: #0e131a; border-top: 1px solid #262d36; }

/* lines from an advance to the ones that need it; a dashed one is a second requirement */
.al { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; filter: drop-shadow(0 0 2px #000); }
.al path { fill: none; stroke: #a88a4f; stroke-width: 6; stroke-linecap: round; }
.al path.x { stroke-dasharray: 16 12; stroke: #8c7a55; }

/* the line over each tree and group */
.ag { position: absolute; padding: 0 30px; font: 400 32px/1.15 var(--display); color: #efe3c2; text-shadow: 0 2px 5px #000; pointer-events: none; }
.ag-tree { transform: translateX(-50%); text-align: center; white-space: nowrap; font-size: 36px; }
.ag small { display: block; margin-top: 4px; font: 400 19px/1.3 var(--body); color: #b9ad8f; }
.ag small img { width: 22px; height: 22px; vertical-align: -5px; margin-right: 3px; }
.ag-placed, .ag-loose { font: 400 21px/1.35 var(--body); color: #cfc4a6; }

/* one advance */
.an { position: absolute; display: block; width: 330px; height: 265px; color: #eee2c4; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.an-card { position: absolute; left: 40px; top: 55px; width: 250px; height: 200px; background: var(--c-greyish); box-shadow: 0 8px 22px rgba(0, 0, 0, .5); }
.an.fl .an-card { background: var(--c-paper); }
.an-t { position: absolute; left: 0; right: 0; top: 47px; height: 40px; display: flex; align-items: center; justify-content: center; padding: 0 18px; overflow: hidden;
  background: var(--c-low-green) url(img/advscreen/band.webp) center / 120px 120px; background-blend-mode: multiply; font: 600 19px/1.02 var(--display); color: #f3e8cb; text-align: center; text-shadow: 0 1px 2px #000; }
.an.fl .an-t { background-color: var(--c-dark-purple); }
.an-fx { position: absolute; left: 8px; right: 8px; top: 93px; bottom: 10px; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.an-e { display: flex; align-items: center; gap: 7px; min-height: 42px; padding: 2px 6px 2px 4px; background: linear-gradient(90deg, rgba(0, 0, 0, .42), rgba(0, 0, 0, .12)); }
.an-e img, .an-e i { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 2px solid #8a7448; background: #1b1812; object-fit: contain; }
.an-e > span { min-width: 0; }
.an-e b, .an-e small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 14.5px/1.15 var(--body); }
.an-e b { color: #eadfc4; }
.an-e small { color: #d9b866; font-size: 14.5px; }
.an-more { position: absolute; right: 2px; bottom: -2px; padding: 0 5px; font: 700 12px/1.4 var(--body); color: #d9b866; background: rgba(0, 0, 0, .55); border-radius: 3px; }
/* the icon fills the round hole of the frame's arch (rows 11 to 106 of the 270 px frame) */
.an-ic { position: absolute; left: 115px; top: 8px; width: 100px; height: 100px; border-radius: 50%; background: var(--c-bg-brown); }
.an-ic::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: url(img/advscreen/bg-green.webp) center / 100% 100%; }
.an-ic.bg-blue::before { background-image: url(img/advscreen/bg-blue.webp); }
.an-ic.bg-red::before { background-image: url(img/advscreen/bg-red.webp); }
.an-ic img { position: absolute; left: 8px; top: 8px; width: 84px; height: 84px; object-fit: cover; -webkit-mask: url(img/advscreen/icon-mask.webp) center / 100% 100%; mask: url(img/advscreen/icon-mask.webp) center / 100% 100%; }
.an-fr { position: absolute; left: 30px; top: -5px; width: 270px; height: 270px; background: url(img/advscreen/frame-up.webp) 0 0 / 100% 100% no-repeat; pointer-events: none; }
.an:hover .an-fr, .an:focus-visible .an-fr { background-image: url(img/advscreen/frame-over.webp); }
.an-un { position: absolute; left: 12px; top: 2px; width: 305px; height: 102px; object-fit: contain; object-position: center bottom; pointer-events: none; opacity: .9; }
.an-f { position: absolute; left: -20px; top: 97px; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--c-dark-purple) url(img/advscreen/circle.webp) center / 100% 100%; box-shadow: 0 2px 6px rgba(0, 0, 0, .6); }
.an-f img { width: 34px; height: 34px; object-fit: contain; }
.an-f-flag img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.an-in { position: absolute; left: 232px; top: 62px; width: 34px; height: 34px; padding: 3px; border-radius: 50%; background: #10141a; box-shadow: 0 0 0 2px #8a7448; }

/* states: researched at the 1337 start, not open yet, depends on more than the start settles, picked, found */
.an.done .an-fr { background-image: url(img/advscreen/frame-done.webp); }
.an.done .an-t { background-color: var(--c-bronze); }
.an.off .an-fr { background-image: url(img/advscreen/frame-off.webp); }
.an.off .an-ic img { filter: grayscale(.85) brightness(.75); }
.an.off .an-card { filter: saturate(.4) brightness(.85); }
.an.maybe .an-card { outline: 3px dashed #b39553; outline-offset: 6px; }
.an.sel .an-card { box-shadow: 0 0 0 4px #f2d27a, 0 0 40px rgba(242, 210, 122, .55); }
.an.hit::before { content: ""; position: absolute; left: 15px; top: -22px; width: 300px; height: 300px; background: url(img/advscreen/frame-search.webp) center / 100% 100% no-repeat; }
.an:focus-visible { outline: none; }

/* far out the game shows only the icons; so do we, and the names grow to stay readable */
.ascr-c.lo .an-fx, .ascr-c.lo .an-un, .ascr-c.lo .an-in, .ascr-c.lo .an-more { display: none; }
.ascr-c.lo .an-t { top: 92px; height: 100px; padding: 0 12px; font-size: 32px; line-height: 1.05; background: none; }
.ascr-c.lo .an-card { background: rgba(20, 18, 14, .55); }
.ascr-c.lo .an-fr { opacity: .55; }

/* the panel */
.ap-close { display: none; }
.ap-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.ap-head .an-ic { position: relative; left: auto; top: auto; flex: none; width: 76px; height: 76px; box-shadow: 0 0 0 5px rgba(30, 24, 17, .75); }
.ap-head .an-ic::before { inset: 8px; }
.ap-head .an-ic img { left: 10px; top: 10px; width: 56px; height: 56px; }
.ap-head h3 { margin: 0; font: 400 1.45rem/1.15 var(--display); color: #fff; }
.ap-head p { margin: 2px 0 0; color: #b2a684; font-size: .88rem; }
.ascr-panel h4 { margin: 14px 0 4px; font: 400 1.1rem/1.2 var(--display); color: #e9d9ad; }
.ascr-panel p { margin: 4px 0; }
.ap-e { list-style: none; margin: 0; padding: 0; }
.ap-e li { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px solid #222a33; }
.ap-e li img, .ap-e li i { flex: none; width: 26px; height: 26px; object-fit: contain; }
.ap-e li span { flex: 1; }
.ap-e li b { font-weight: 600; color: #d9b866; white-space: nowrap; }
.ap-i { width: 22px; height: 22px; vertical-align: -5px; margin-right: 4px; }
.ap-hid { color: #e0b46a; }
.ap-small { color: #a99d80; font-size: .88rem; }
.ap-desc { color: #c9bfa6; font-style: italic; margin-top: 12px !important; }
.ap-page { display: inline-block; margin-top: 8px; }

/* the card on an advance's own page */
.adv-solo { float: right; width: 330px; margin: 0 0 14px 24px; }
.adv-solo .ascr-c { position: relative; transform: none; width: 330px; height: 265px; margin-top: 8px; }
.adv-solo p { margin: 10px 0 0; font-size: .9rem; color: var(--muted); }
.adv-solo { --c-low-green: #2b3431; --c-dark-purple: #3b223b; --c-bronze: #3e2e15; --c-greyish: #2e2c26; --c-paper: #473c31; --c-bg-brown: #3b3023; }

@media (max-width: 860px) {
  .ascr { margin-left: -8px; margin-right: -8px; border-radius: 0; }
  .ascr-tabs a { font-size: 15px; padding: 8px 10px; }
  .ascr-head { min-height: 0; padding: 12px; }
  .ascr-age b { font-size: 22px; }
  .ascr-inst a { padding: 3px 9px 3px 4px; font-size: .88rem; }
  .ascr-inst img { width: 26px; height: 26px; }
  .ascr-bar { gap: 6px; padding: 6px 8px; }
  .ascr-bar input { height: 36px; font-size: 14px; }
  .ascr-country { flex: 1 1 50%; max-width: none; order: 1; }
  .ascr-zoom { order: 2; }
  .ascr-focus { order: 3; flex: 0 1 auto; gap: 4px; }
  .ascr-find { order: 4; flex: 1 1 30%; min-width: 0; }
  .ascr-focus button { height: 34px; padding: 0 7px 0 3px; gap: 3px; font-size: 12.5px; }
  .ascr-focus button img { width: 22px; height: 22px; }
  .ascr-focus button span { display: none; }
  .ascr-focus button .fs { display: inline; }
  .ascr-zoom button { min-width: 34px; height: 34px; padding: 0 6px; font-size: 15px; }
  .ascr-main { grid-template-columns: minmax(0, 1fr); }
  .ascr-view { height: 64vh; }
  .ascr-c { transform: translate(24px, 0) scale(.36); }
  .ascr-panel { display: none; position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 60; height: auto; max-height: 72vh; border-left: 0; border-top: 1px solid #8a6d2a; box-shadow: 0 -10px 30px rgba(0, 0, 0, .55); padding-top: 4px; }
  .ascr-panel.open { display: block; }
  .ascr-panel .ascr-hint { display: none; }
  .ap-close { display: block; position: sticky; top: 0; margin: 0 -8px 0 auto; width: 44px; height: 40px; border: 0; background: none; color: #eadfc4; font: 400 30px/1 sans-serif; cursor: pointer; }
  .ap-head { margin-top: -34px; }
  .adv-solo { float: none; margin: 0 auto 14px; }
}
