/* The site of "כאן תקום עיר": the valley fills the screen; over it, paper panels in the series' colours.
   Layout: a slim bar at the top (how many live here, the stages), a sheet at the bottom on a phone (a side panel on a wide
   screen) to find your tent, labels floating over the valley. */
:root {
  --paper: #fff8ec;        /* the panels: warm paper */
  --sand: #f2e2c4;         /* quiet buttons, chips */
  --sand-2: #e4cfa7;       /* lines on paper */
  --ink: #2b2118;          /* text: dark brown, never black */
  --ink-2: #6e5a45;        /* secondary text */
  --key: #ff9a3c;          /* the series' orange (KEY in overlay.js) */
  --key-ink: #2b1606;      /* text on orange */
  --key-deep: #c4600f;     /* the orange's edge */
  --night: rgba(36, 27, 19, 0.8);
  --display: 'Rubik', 'Heebo', 'Arial Hebrew', system-ui, sans-serif;
  --body: 'Heebo', 'Rubik', 'Arial Hebrew', system-ui, sans-serif;
  --gut: max(12px, env(safe-area-inset-left, 0px));
  --gut-r: max(12px, env(safe-area-inset-right, 0px));
  --lift: 0 12px 32px rgba(43, 33, 24, 0.26), 0 2px 6px rgba(43, 33, 24, 0.16);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: #d9bd92; color: var(--ink); font: 400 15px/1.45 var(--body); -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--key-deep); outline-offset: 2px; }
[hidden] { display: none !important; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* --- the loading poster: the sky at golden hour, the sign's words */
#poster { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; text-align: center; transition: opacity 0.7s ease 0.2s;
  background: linear-gradient(180deg, #5f8fc4 0%, #9cb7cf 34%, #f2d4a8 62%, #e2bb86 63%, #d6ad78 100%); }
#poster div { display: grid; gap: 10px; }
#poster b { font: 800 clamp(40px, 11vw, 72px)/1 var(--display); color: var(--ink); letter-spacing: -0.01em; }
#poster span { font: 500 16px var(--body); color: var(--ink-2); }
#poster.gone { opacity: 0; pointer-events: none; }

/* --- the top bar */
#bar { position: fixed; z-index: 10; top: calc(env(safe-area-inset-top, 0px) + 10px); left: var(--gut); right: var(--gut-r);
  background: var(--night); color: #fbefd9; border-radius: 16px; padding: 10px 14px 10px; box-shadow: var(--lift);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
#bar .row { display: flex; align-items: center; gap: 10px; }
#bar .brand { font: 800 19px/1 var(--display); letter-spacing: -0.01em; }
#bar .count { margin-inline-start: auto; font: 600 13px/1 var(--display); color: #e9d6b6; white-space: nowrap; }
#bar .count b { display: inline-block; min-width: 1.6em; padding: 4px 8px; border-radius: 8px; background: var(--key); color: var(--key-ink); font: 800 15px/1 var(--display); text-align: center; font-variant-numeric: tabular-nums; }
#bar .sky { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255, 248, 236, 0.14); color: #fbefd9; font: 800 17px/1 var(--display); display: grid; place-items: center; }
#bar .count + .sky { margin-inline-start: 2px; }
.stages { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.stages li { position: relative; display: grid; justify-items: start; gap: 4px; font: 600 11px/1 var(--display); color: #bfa98a; }
.stages li i { position: relative; width: 100%; height: 6px; border-radius: 3px; background: rgba(255, 248, 236, 0.16); overflow: hidden; }
.stages li i::after { content: ''; position: absolute; inset: 0; inset-inline-end: auto; width: calc(var(--fill, 0) * 100%); background: var(--key); border-radius: 3px; }
.stages li + li i { margin-inline-start: 3px; width: calc(100% - 3px); }
.stages li.done { color: #fbefd9; }
.stages li span::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 248, 236, 0.3); margin-inline-end: 5px; vertical-align: 1px; }
.stages li.done span::before { background: var(--key); }
#bar .next { margin: 8px 0 0; font: 500 13px/1.3 var(--body); color: #f1dfc0; }
body.dream #bar .next { color: var(--key); font-weight: 700; }

/* --- labels over the valley */
#tags { position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; pointer-events: auto; border: 0; white-space: nowrap; padding: 6px 11px 7px; border-radius: 999px;
  background: var(--paper); color: var(--ink); font: 700 13px/1 var(--display); box-shadow: 0 3px 10px rgba(43, 33, 24, 0.25); transition: opacity 0.2s; will-change: transform; }
.tag::after { content: ''; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: inherit; }
.tag { border-top-color: var(--paper); }
.tag.hut { background: rgba(255, 248, 236, 0.92); font-weight: 600; }
.tag.mine, .tag.picked { background: var(--key); color: var(--key-ink); font-size: 14px; padding: 8px 13px 9px; }
.tag.mine::after, .tag.picked::after { border-top-color: var(--key); }
.tag.ghost { background: rgba(255, 248, 236, 0.9); outline: 2px dashed var(--key-deep); outline-offset: -2px; }
.tag.dim { opacity: 0; pointer-events: none; }

/* --- the sheet: at the bottom on a phone */
#sheet { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; max-height: min(72vh, 620px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 34px rgba(43, 33, 24, 0.24);
  padding: 4px var(--gut-r) calc(14px + env(safe-area-inset-bottom, 0px)) var(--gut); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
#grab { display: block; width: 64px; height: 22px; margin: 0 auto; border: 0; background: none; position: relative; }
#grab::before { content: ''; position: absolute; left: 50%; top: 8px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--sand-2); }
#home, #card, #future { display: grid; gap: 12px; }
#sheet.low #home > :not(#find), #sheet.low #card > :not(.cardhead), #sheet.low #future > :not(.cardhead) { display: none; }

.today { display: flex; gap: 8px; align-items: flex-start; padding: 9px 12px; border-radius: 12px; background: #fdebd2; color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.35; }
.today b { font-family: var(--display); }
.today::after { content: '←'; margin-inline-start: auto; color: var(--key-deep); font-weight: 700; }
.findhead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.findhead label { font: 800 21px/1.1 var(--display); letter-spacing: -0.01em; }
.pill { margin-inline-start: auto; border: 0; border-radius: 999px; padding: 7px 12px; font: 700 13px/1 var(--display); white-space: nowrap; }
.pill.key { background: var(--key); color: var(--key-ink); }
.field { display: flex; align-items: stretch; height: 52px; border: 2px solid var(--ink); border-radius: 14px; background: #fff; overflow: hidden; }
.field input { flex: 1; min-width: 0; border: 0; outline: none; background: none; padding: 0 12px 0 0; font: 500 17px var(--body); text-align: left; }
.field input::placeholder { color: #a8957c; text-align: right; direction: rtl; }
/* right to left: the name box, the @ just before the name, the button at the far end */
.field .at { display: grid; place-items: center; padding-inline: 2px 10px; color: var(--ink-2); font: 600 17px var(--body); }
.field button { flex: none; border: 0; background: var(--ink); color: var(--paper); padding: 0 18px; font: 700 16px var(--display); }
.field:focus-within { box-shadow: 0 0 0 3px rgba(255, 154, 60, 0.45); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding-inline: max(16px, env(safe-area-inset-left, 0px)); padding-block: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 0; border-radius: 999px; padding: 9px 13px; background: var(--sand); font: 600 14px/1 var(--display); color: var(--ink); white-space: nowrap; }
.chips button:active { background: var(--sand-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 16px; border: 0; border-radius: 14px; font: 700 16px/1.15 var(--display); text-decoration: none; text-align: center; }
.btn.key { background: var(--key); color: var(--key-ink); box-shadow: 0 3px 0 var(--key-deep); }
.btn.key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--key-deep); }
.btn.light { background: var(--sand); color: var(--ink); }
.btn.grow, .grow.btn { flex: 1; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.link { border: 0; background: none; padding: 0; color: var(--key-deep); font: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* cards */
.cardhead { display: flex; align-items: flex-start; gap: 12px; }
.cardhead > div { flex: 1; min-width: 0; }
.cardhead h2 { margin: 0; font: 800 21px/1.15 var(--display); letter-spacing: -0.01em; text-wrap: balance; overflow-wrap: anywhere; }
.cardhead .sub { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.x { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--sand); font-size: 15px; display: grid; place-items: center; }
.swatch { flex: none; width: 40px; height: 40px; border-radius: 12px 12px 6px 6px; background: var(--c); box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.12); clip-path: polygon(50% 0, 100% 78%, 100% 100%, 0 100%, 0 78%); }
.swatch.ghost { background: rgba(255, 154, 60, 0.35); outline: 2px dashed var(--key-deep); outline-offset: -2px; clip-path: none; border-radius: 12px; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.facts li { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: #fbf0dc; }
.facts b { font: 800 17px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.facts span { font-size: 12.5px; color: var(--ink-2); }
.lead { margin: 0; font-size: 16px; line-height: 1.5; }
.small { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.small a { color: inherit; }
.why { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 14.5px; }
.why b { font-family: var(--display); }
.archive { margin: 0; position: relative; border-radius: 14px; overflow: hidden; background: #e8dcc6; aspect-ratio: 2 / 1; max-width: 100%; }
.archive img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 38%; display: block; filter: sepia(0.18) contrast(1.04); }
.archive figcaption { position: absolute; right: 10px; bottom: 10px; padding: 5px 9px; border-radius: 8px; background: rgba(43, 33, 24, 0.82); color: #fbefd9; font: 700 12px/1 var(--display); }
.credit { font-size: 11.5px; }

/* the stages */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--sand); }
.seg button { border: 0; border-radius: 10px; padding: 10px 4px; background: none; font: 700 15px/1 var(--display); color: var(--ink-2); }
.seg button[aria-checked="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 6px rgba(43, 33, 24, 0.16); }

/* what was built: its story */
.swatch.build { display: grid; place-items: center; background: var(--sand); clip-path: none; border-radius: 12px; font-size: 22px; box-shadow: none; }
.idea { margin: 0; padding: 12px 14px; border-radius: 12px; background: #fdebd2; font: 700 17px/1.4 var(--display); border-inline-start: 4px solid var(--key); }
.tag.built { background: #fdebd2; }
.tag.built::after { border-top-color: #fdebd2; }

/* the resident card for a story */
.panel.story { max-width: 380px; gap: 12px; }
.storyimg { display: grid; place-items: center; min-height: 240px; }
.storyimg img { display: block; width: 100%; max-height: 60vh; object-fit: contain; border-radius: 16px; box-shadow: 0 6px 18px rgba(43, 33, 24, 0.25); }
.making { color: var(--ink-2); }

/* the how-it-works box */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); background: rgba(30, 22, 14, 0.5); }
.panel { width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto; background: var(--paper); border-radius: 22px; padding: 22px 20px 18px; box-shadow: var(--lift); display: grid; gap: 14px; }
.panel h2 { margin: 0; font: 800 23px/1.15 var(--display); text-wrap: balance; }
.panel h3 { margin: 4px 0 -6px; font: 800 16px/1.2 var(--display); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps li > span { flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--sand); display: grid; place-items: center; font-size: 19px; }
.steps b { display: block; font: 800 16px/1.3 var(--display); }
.panel .grow { margin: 0; padding: 10px 12px; border-radius: 12px; background: #fdebd2; font-size: 14.5px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.log li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: baseline; }
.log b { font: 700 13px var(--display); color: var(--key-deep); white-space: nowrap; font-variant-numeric: tabular-nums; }

#toast { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 128px); max-width: calc(100% - 32px); width: max-content;
  padding: 10px 14px; border-radius: 12px; background: var(--night); color: #fbefd9; font: 600 14px/1.35 var(--display); text-align: center; box-shadow: var(--lift); pointer-events: none; }

/* the link-preview picture */
#ogtitle { display: none; }
body.og #bar, body.og #sheet, body.og #tags, body.og #toast, body.og #poster { display: none !important; }
body.og #ogtitle { display: grid; gap: 10px; position: fixed; z-index: 30; top: 44px; right: 56px; left: 56px; }
body.og #ogtitle b { font: 800 84px/1 var(--display); color: var(--ink); letter-spacing: -0.015em; text-shadow: 0 2px 0 rgba(255, 248, 236, 0.6); }
body.og #ogtitle span { font: 600 30px/1.2 var(--display); color: var(--ink); }

/* a wide screen: the sheet becomes a panel on the right, the bar stays over the valley beside it */
@media (min-width: 900px), (orientation: landscape) and (max-height: 520px) {
  #sheet { left: auto; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(env(safe-area-inset-top, 0px) + 16px); bottom: auto; width: 380px; max-height: calc(100% - 32px);
    border-radius: 20px; padding: 16px 18px 18px; box-shadow: var(--lift); }
  #grab { display: none; }
  #bar { right: calc(max(16px, env(safe-area-inset-right, 0px)) + 380px + 16px); left: auto; width: min(480px, calc(100% - 380px - 48px)); top: calc(env(safe-area-inset-top, 0px) + 16px); }
  #toast { left: calc((100% - 412px) / 2); top: auto; bottom: 28px; }
  .chips { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #sheet { width: 340px; }
  #bar { right: calc(max(16px, env(safe-area-inset-right, 0px)) + 340px + 16px); width: min(420px, calc(100% - 340px - 48px)); }
  .stages { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
