/* The game as Figure 3 of the NetHack+ post embeds it (nethack-plus.html loads
   play.html?embed=1 in an iframe): the post's light theme, and just the game.

   Every rule is scoped to html.embed, the class play.html sets when the URL
   has ?embed, so the standalone console (play.html, index.html, replays.html)
   keeps its dark theme and its sidebar, and console.css / console.extra.css
   stay untouched. The behaviour that goes with these rules is in embed.js.

   An iframe does not inherit the parent's custom properties, so the values
   below are copied from the post's stylesheet, css/nethack-plus.css (:root and
   the #knob-gallery block that themes Figure 4). That page is light only, so
   this is too. Keep the two in sync by hand when the post's palette changes. */

html.embed{
  color-scheme:light;

  /* the post's fonts and accents */
  --head:'Open Sans',sans-serif;
  --sans:'Source Sans Pro','Open Sans',sans-serif;
  --mono:'Consolas','Menlo','Monaco','Courier New',monospace;
  --map:'Menlo','Consolas','SFMono-Regular','Liberation Mono',monospace;  /* .tty */
  --btn:#f5f5f5;                       /* grey buttons, code and kbd */
  --ink-mid:#555555;                   /* their text, and headings */
  --peri:#A5BAE0;                      /* chosen */
  --peri-hover:rgba(165,186,224,.75);  /* hovered */

  /* console.css's variables, re-pointed at the post's light palette */
  --bg:#ffffff;                        /* .post .window */
  --tile-a:#ffffff;
  --tile-b:#ffffff;
  --panel:#ffffff;
  --panel-2:#ffffff;
  --line:#e6e8ee;
  --line-soft:#eeeeee;
  --ctl-border:#8a8f9c;                /* 3:1 on white, for input borders */
  --ink:#444444;
  --ink-dim:#666666;
  --ink-faint:#777777;
  --focus:#9C76C8;
  --hero:#9C76C8;
  --stairs:#2f6fd6;
  --item:#b04cc4;
  --monster:#8427a5;
  --wall:#7c8294;
  --floor:#9aa0b0;
  --good:#0f6b38;
  --warn:#a86a00;
  --danger:#d0453f;

  /* NetHack's 16 colours on a white map. 0, 7 and 9-15 are the values Figure 4
     uses (#knob-gallery .kcN). Figure 4 gives each normal/bright pair nearly
     the same value, which is fine for a picture but not for play (lichen and
     green mold are both F and differ only in green vs bright green), so 1-6
     are darker shades of the same hues. 8 is the remembered dark floor and
     the "black" monsters; Figure 4's #aab0bd is too faint for a letter. */
  --nh-0:#444444;  --nh-1:#a8201f;  --nh-2:#0f6b38;  --nh-3:#7e4e00;
  --nh-4:#1a4fae;  --nh-5:#8427a5;  --nh-6:#0b6c7d;  --nh-7:#7c8294;
  --nh-8:#9aa0b0;  --nh-9:#d0602a;  --nh-10:#2f9e4f; --nh-11:#b07d0b;
  --nh-12:#2f6fd6; --nh-13:#b04cc4; --nh-14:#1f9fb3; --nh-15:#222222;
}

/* ---------- map colours ----------
   console.js writes each glyph as <span style="color:#hex"> from its dark
   palette (PALETTE, then the CHARCOL and literal fallbacks used when a frame
   has no colours). Re-map each of those values here, so console.js stays
   byte-identical to the local console's copy. */
html.embed .screen span[style="color:#6b6b78"]{color:var(--nh-0) !important}
html.embed .screen span[style="color:#c44"]{color:var(--nh-1) !important}
html.embed .screen span[style="color:#4b4"]{color:var(--nh-2) !important}
html.embed .screen span[style="color:#b83"]{color:var(--nh-3) !important}
html.embed .screen span[style="color:#46c"]{color:var(--nh-4) !important}
html.embed .screen span[style="color:#b5b"]{color:var(--nh-5) !important}
html.embed .screen span[style="color:#5bb"]{color:var(--nh-6) !important}
html.embed .screen span[style="color:#bbb"]{color:var(--nh-7) !important}
html.embed .screen span[style="color:#666"]{color:var(--nh-8) !important}
html.embed .screen span[style="color:#f66"]{color:var(--nh-9) !important}
html.embed .screen span[style="color:#6f6"]{color:var(--nh-10) !important}
html.embed .screen span[style="color:#fd5"]{color:var(--nh-11) !important}
html.embed .screen span[style="color:#6af"]{color:var(--nh-12) !important}
html.embed .screen span[style="color:#f6f"]{color:var(--nh-13) !important}
html.embed .screen span[style="color:#6ff"]{color:var(--nh-14) !important}
html.embed .screen span[style="color:#fff"]{color:var(--nh-15) !important}
html.embed .screen span[style="color:#777"],
html.embed .screen span[style="color:#aaa"]{color:var(--nh-7) !important}
html.embed .screen span[style="color:#556"]{color:var(--nh-8) !important}
html.embed .screen span[style="color:#d6d"]{color:var(--nh-13) !important}

/* ---------- page ---------- */
html.embed,html.embed *{scrollbar-width:thin;scrollbar-color:#c4c8d2 transparent}
html.embed body{background:var(--bg);font-family:var(--sans)}
html.embed h2,html.embed h3{
  font-family:var(--head);font-size:14px;font-weight:600;letter-spacing:0;
  color:var(--ink-mid);border-bottom-color:var(--line-soft);padding-bottom:5px;
}

/* ---------- game column ---------- */
html.embed #message,html.embed #status,html.embed #popup,html.embed #inv{font-family:var(--mono)}
html.embed #message{color:var(--ink)}
html.embed #status{color:var(--ink-dim)}
html.embed .screen{
  font-family:var(--map);background:var(--bg);
  outline:1px solid var(--line);border-radius:5px;box-shadow:none;
}
/* the prompt box: the post's hover-card, a rule with a periwinkle edge */
html.embed #popup{
  color:var(--ink);background:var(--bg);box-shadow:none;
  border:1px solid var(--line);border-left:4px solid var(--peri);border-radius:5px;
}
html.embed #invbox{border-radius:5px}
html.embed #invbox > summary{font-family:var(--head);font-size:13px;letter-spacing:0;color:var(--ink-dim)}
html.embed #inv .invgrp{font-family:var(--sans);font-size:12px;letter-spacing:0;color:var(--ink-faint)}
html.embed #invbox.flash{animation-name:invflash-embed}
@keyframes invflash-embed{
  0%{border-color:var(--peri);box-shadow:0 0 0 3px rgba(165,186,224,.5)}
  100%{border-color:var(--line);box-shadow:none}
}
html.embed #hint{font-size:13px;line-height:1.45}
html.embed #hint b{font-weight:600;color:var(--ink-mid)}
html.embed #hint kbd{
  font-family:var(--mono);font-size:11.5px;background:var(--btn);color:var(--ink-mid);
  border:0;border-radius:4px;padding:1px 5px;
}

/* ---------- just the game ----------
   The figure is for playing, so the sidebar is gone: no six-level curriculum,
   no settings to flip, no editing of the hero's state. embed.js moves the four
   actions that belong to play (undo, checkpoint, restore, new game) under the
   map, turns reveal_map on, and sizes the map to the width of the figure. */
html.embed #side{display:none}
html.embed.framed{overflow:hidden}      /* the post sizes the iframe to the game, so nothing scrolls inside it */
html.embed .page{display:block;min-height:0}
html.embed .maincol{display:block;padding:14px 16px 16px}
html.embed .console{display:grid;grid-template-columns:minmax(0,1fr);max-width:none}
html.embed .console > *{min-width:0}
@media (min-width:720px){
  /* inventory and key list side by side under the map, so the figure stays short */
  html.embed .console{grid-template-columns:minmax(0,1fr) minmax(0,1fr);column-gap:28px;align-items:start}
  html.embed .console > :not(#invbox):not(#hint){grid-column:1 / -1}
}
html.embed #hint{max-width:none;margin-top:8px}

/* The map takes the whole width: embed.js sets the font size so that the 79
   columns fill the box, and the 21 rows are reserved before the engine has
   drawn anything, so the figure does not jump when the game appears. */
html.embed .screen{
  position:relative;padding:8px;text-align:center;cursor:pointer;
  min-height:calc(21 * 1.15em + 16px);box-sizing:border-box;
}
/* Always show which element takes the keys, also after a mouse click. */
html.embed .screen:focus{outline:2px solid var(--focus)}
html.embed .screen::after{
  position:absolute;top:8px;right:10px;padding:3px 9px;border-radius:5px;
  font:600 12px/1.4 var(--sans);letter-spacing:0;background:var(--peri);color:#ffffff;
  pointer-events:none;
}
html.embed:not(.ready) .screen::after{content:"Loading the engine (about 5 MB)\2026";background:var(--btn);color:var(--ink-mid)}
html.embed.ready:not(.over) .screen:not(:focus)::after{content:"Click the map to play"}
html.embed.over .screen::after{content:"Game over"}

/* ---------- actions under the map ---------- */
html.embed #embedtools{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:10px}
html.embed #embedtools .act-btn{
  width:auto;margin:0;padding:6px 12px;flex:0 0 auto;
  font-family:var(--sans);font-size:13px;letter-spacing:0;text-shadow:none;
  background:var(--btn);color:var(--ink-mid);border:1px solid transparent;border-radius:5px;
}
html.embed #embedtools .act-btn:hover{filter:none;background:var(--peri-hover);color:#ffffff}
html.embed #embedtools .act-btn:disabled{background:var(--btn);color:var(--ink-mid)}
html.embed.over #reset{background:var(--peri);color:#ffffff}
html.embed #embednote,html.embed #markstat{
  font-family:var(--sans);font-size:12.5px;color:var(--ink-faint);min-height:0;margin:0;
}
html.embed #seedrow{margin:0 0 0 auto;font-family:var(--mono);font-size:12px;color:var(--ink-faint)}
html.embed #seed{
  width:64px;font-family:var(--mono);font-size:12px;background:var(--bg);color:var(--ink);
  border:1px solid var(--ctl-border);border-radius:4px;
}

@media (prefers-contrast: more){
  html.embed{--ink:#222222;--ink-dim:#444444;--ink-faint:#555555;
             --line:#aab0bd;--line-soft:#c4c8d2;--ctl-border:#5d6478;--nh-7:#5d6478;--nh-8:#7c8294}
  html.embed .screen:focus{outline-width:3px}
}
