/*
 * Imperial Hackers Online: a green-screen terminal skin, scoped to .ih-game so it doesn't disturb the theme.
 *
 * Colour and font rules repeat the wrapper class (.ih-game.ih-game) to outrank theme rules such as
 * Twenty Twenty-Five's ".wp-block-post-content p", which would otherwise paint the game's text in the
 * theme's dark grey. Utility classes repeat it too, so they still win inside the game.
 */
.ih-game {
  --ih-bg: #020604;
  --ih-panel: #07110b;
  --ih-border: #1d4a2c;
  --ih-text: #d6f5df;
  --ih-dim: #8fb79b;
  --ih-cyan: #7ffbff;
  --ih-yellow: #ffef6b;
  --ih-green: #7dff7d;
  --ih-magenta: #ff8bff;
  --ih-red: #ff8080;
  --ih-blue: #86bcff;
  --ih-ink: #020604;
  --ih-field: #0b1a10;
  --ih-field-border: #3fbf6a;
  --ih-font: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  /* How far the game breaks out of the theme's content column, each side. */
  --ih-bleed: 10%;

  background: var(--ih-bg);
  color: var(--ih-text);
  font-family: var(--ih-font);
  font-size: 15px;
  line-height: 1.5;
  padding: 16px;
  border: 1px solid var(--ih-border);
  border-radius: 6px;
  box-sizing: border-box;
}

/*
 * Game screens carry a lot of numbers and wide tables, so the box fills whatever content width the
 * theme allows and, on a desktop, runs 20% wider than that column: 10% out of each side, re-centred
 * on its own column. It never exceeds the viewport, and below the breakpoint it fills the column
 * normally. To change how much wider it runs, set --ih-bleed to half the extra width.
 */
@media (min-width: 900px) {
  .ih-game {
    width: min(calc(100% + (var(--ih-bleed) * 2)), calc(100vw - 32px));
    margin-left: 50%;
    transform: translateX(-50%);
  }
  /* A compact feed lives in someone else's column (a sidebar widget), so it stays inside it. */
  .ih-game.ih-compact { width: auto; margin-left: 0; transform: none; }
}
.ih-game.ih-compact { padding: 10px; font-size: 14px; }
.ih-game.ih-compact .ih-title { display: none; }
.ih-game.ih-compact .ih-panel { margin-bottom: 0; }
.ih-game *, .ih-game *::before, .ih-game *::after { box-sizing: border-box; }

/* Base typography: force the game's own colours and monospace font over the theme's. */
.ih-game.ih-game p, .ih-game.ih-game li, .ih-game.ih-game td, .ih-game.ih-game th,
.ih-game.ih-game dd, .ih-game.ih-game dt, .ih-game.ih-game label, .ih-game.ih-game summary,
.ih-game.ih-game blockquote, .ih-game.ih-game figcaption, .ih-game.ih-game strong, .ih-game.ih-game em {
  color: var(--ih-text);
  font-family: var(--ih-font);
}
.ih-game.ih-game h1, .ih-game.ih-game h2, .ih-game.ih-game h3, .ih-game.ih-game h4 {
  font-family: var(--ih-font); color: var(--ih-cyan); margin: 0 0 .6em; line-height: 1.25;
}
.ih-game.ih-game h2 { font-size: 1.3em; }
.ih-game.ih-game h3 { font-size: 1.05em; color: var(--ih-yellow); }
.ih-game.ih-game p { margin: 0 0 .8em; }
.ih-game.ih-game a { color: var(--ih-cyan); }
.ih-game.ih-game a:hover, .ih-game.ih-game a:focus { color: var(--ih-yellow); }

/* Utility colours, one step more specific again so they win on any element. */
.ih-game.ih-game .ih-dim { color: var(--ih-dim); }
.ih-game.ih-game .ih-good { color: var(--ih-green); }
.ih-game.ih-game .ih-bad { color: var(--ih-red); }
.ih-game.ih-game .ih-buy { color: var(--ih-green); }
.ih-game.ih-game .ih-sell { color: var(--ih-cyan); }
.ih-game.ih-game .ih-special { color: var(--ih-magenta); font-weight: bold; }
/* The specialist chip after a port's class code: BBS followed by a diamond and an initial. */
.ih-game.ih-game .ih-risk { white-space: nowrap; letter-spacing: 1px; }
.ih-game.ih-game .ih-spec-chip { font-weight: bold; white-space: nowrap; font-size: .9em; letter-spacing: 0; }
.ih-game.ih-game .ih-beacon { color: var(--ih-magenta); }
.ih-game.ih-game .ih-big { font-size: 2em; color: var(--ih-yellow); margin: 0; }
.ih-small { font-size: .85em; }
.ih-port-code { font-weight: bold; letter-spacing: .1em; }

.ih-title { color: var(--ih-magenta); font-weight: bold; letter-spacing: .15em; text-transform: uppercase; margin-bottom: 10px; }

.ih-status { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 12px; background: var(--ih-panel); border: 1px solid var(--ih-border); border-radius: 4px; margin-bottom: 8px; font-size: .9em; }
.ih-game.ih-game .ih-label { color: var(--ih-dim); }
.ih-stat { white-space: nowrap; }

.ih-turnbar { padding: 7px 12px; margin-bottom: 8px; border: 1px dashed var(--ih-border); border-left: 3px solid var(--ih-yellow); border-radius: 3px; background: var(--ih-panel); font-size: .85em; line-height: 1.6; }
.ih-game.ih-game .ih-turnbar strong { color: var(--ih-yellow); }
.ih-turnbar-empty { border-left-color: var(--ih-red); }
.ih-game.ih-game .ih-turnbar-empty strong { color: var(--ih-red); }

.ih-nav, .ih-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.ih-game.ih-game .ih-nav a, .ih-game.ih-game .ih-tabs a { padding: 5px 11px; border: 1px solid var(--ih-border); border-radius: 3px; text-decoration: none; color: var(--ih-text); background: var(--ih-panel); }
.ih-game.ih-game .ih-nav a:hover, .ih-game.ih-game .ih-tabs a:hover { border-color: var(--ih-cyan); color: var(--ih-cyan); }
.ih-game.ih-game .ih-nav a.ih-active, .ih-game.ih-game .ih-tabs a.ih-active { background: var(--ih-cyan); color: var(--ih-ink); border-color: var(--ih-cyan); }
.ih-game.ih-game .ih-badge { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 1em; background: var(--ih-red); color: var(--ih-ink); font-weight: bold; font-size: .8em; text-align: center; }

.ih-panel { background: var(--ih-panel); border: 1px solid var(--ih-border); border-radius: 4px; padding: 14px 16px; margin-bottom: 14px; }
.ih-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.ih-grid > .ih-panel { margin-bottom: 0; }
.ih-grid + .ih-panel, .ih-grid + .ih-grid { margin-top: 14px; }

.ih-flash { padding: 10px 14px; border-left: 4px solid; margin-bottom: 10px; background: var(--ih-panel); }
.ih-game.ih-game .ih-flash-success { border-color: var(--ih-green); color: var(--ih-green); }
.ih-game.ih-game .ih-flash-warning { border-color: var(--ih-yellow); color: var(--ih-yellow); }
.ih-game.ih-game .ih-flash-error { border-color: var(--ih-red); color: var(--ih-red); }

/*
 * Buttons. These are a mix of <a> and <button>, so the rules repeat the wrapper class to beat both
 * the theme's link colours and the game's own link rule: without that, a link-styled button showed
 * cyan text on its cyan background, and yellow on yellow when hovered.
 */
.ih-game.ih-game .ih-btn {
  display: inline-block; font-family: var(--ih-font); font-size: .92em; line-height: 1.2;
  padding: 6px 12px; border-radius: 3px; border: 1px solid var(--ih-cyan);
  background: var(--ih-cyan); color: var(--ih-ink); cursor: pointer; text-decoration: none; margin: 2px 0;
}
.ih-game.ih-game a.ih-btn, .ih-game.ih-game a.ih-btn:visited { color: var(--ih-ink); text-decoration: none; }
.ih-game.ih-game .ih-btn:hover, .ih-game.ih-game .ih-btn:focus,
.ih-game.ih-game a.ih-btn:hover, .ih-game.ih-game a.ih-btn:focus {
  background: var(--ih-yellow); border-color: var(--ih-yellow); color: var(--ih-ink);
}
.ih-game.ih-game .ih-btn-alt, .ih-game.ih-game a.ih-btn-alt, .ih-game.ih-game a.ih-btn-alt:visited { background: transparent; color: var(--ih-cyan); }
.ih-game.ih-game .ih-btn-alt:hover, .ih-game.ih-game .ih-btn-alt:focus,
.ih-game.ih-game a.ih-btn-alt:hover, .ih-game.ih-game a.ih-btn-alt:focus { background: var(--ih-yellow); color: var(--ih-ink); }
.ih-game.ih-game .ih-btn-danger, .ih-game.ih-game a.ih-btn-danger, .ih-game.ih-game a.ih-btn-danger:visited { background: var(--ih-red); border-color: var(--ih-red); color: var(--ih-ink); }
.ih-game.ih-game .ih-btn-danger:hover, .ih-game.ih-game a.ih-btn-danger:hover { background: var(--ih-yellow); border-color: var(--ih-yellow); color: var(--ih-ink); }
.ih-game.ih-game .ih-btn-small { padding: 3px 8px; font-size: .82em; }
/* A link-styled action: the sector numbers that fly you to a port and dock. It is a real
   submit button so the action keeps its nonce, and only looks like a link. */
.ih-game.ih-game .ih-linkish {
  display: inline; font-family: var(--ih-font); font-size: 1em; line-height: inherit;
  padding: 0; margin: 0; border: 0; background: none; color: var(--ih-cyan);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.ih-game.ih-game .ih-linkish:hover, .ih-game.ih-game .ih-linkish:focus { color: var(--ih-yellow); }
.ih-game .ih-linkish:focus-visible { outline: 2px solid var(--ih-yellow); outline-offset: 2px; }

.ih-game .ih-btn:focus-visible, .ih-game a:focus-visible, .ih-game input:focus-visible, .ih-game select:focus-visible, .ih-game textarea:focus-visible { outline: 2px solid var(--ih-yellow); outline-offset: 2px; }

/*
 * Entry fields. The old 1px border in the panel colour was only 1.48:1 against the panel, so on a
 * phone you could not see where to tap. They now sit on a lighter field colour with a clearly
 * visible border (6.5:1), and grow a brighter border and a glow when focused.
 */
.ih-game.ih-game input[type=text], .ih-game.ih-game input[type=number], .ih-game.ih-game input[type=password],
.ih-game.ih-game select, .ih-game.ih-game textarea {
  font-family: var(--ih-font); font-size: .95em; background: var(--ih-field); color: var(--ih-yellow);
  border: 1px solid var(--ih-field-border); border-radius: 3px; padding: 6px 8px; max-width: 100%;
  min-height: 36px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .45);
}
.ih-game.ih-game input[type=text]:hover, .ih-game.ih-game input[type=number]:hover,
.ih-game.ih-game input[type=password]:hover, .ih-game.ih-game select:hover, .ih-game.ih-game textarea:hover {
  border-color: var(--ih-cyan);
}
.ih-game.ih-game input[type=text]:focus, .ih-game.ih-game input[type=number]:focus,
.ih-game.ih-game input[type=password]:focus, .ih-game.ih-game select:focus, .ih-game.ih-game textarea:focus {
  border-color: var(--ih-cyan); background: #0a1322; box-shadow: 0 0 0 2px rgba(127, 251, 255, .35);
}
.ih-game.ih-game input::placeholder, .ih-game.ih-game textarea::placeholder { color: var(--ih-dim); opacity: 1; }
.ih-game textarea { width: 100%; }
.ih-num { width: 7em; }
.ih-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 4px 2px 0; }
.ih-stack { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.ih-stack label { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 420px; }
.ih-stack input, .ih-stack select { width: 100%; }

.ih-table-wrap { overflow-x: auto; }
.ih-table { width: 100%; border-collapse: collapse; margin-bottom: .8em; font-size: .92em; }
.ih-game.ih-game .ih-table th, .ih-game.ih-game .ih-table td { border-bottom: 1px solid var(--ih-border); padding: 6px 8px; text-align: left; vertical-align: middle; }
.ih-game.ih-game .ih-table th { color: var(--ih-dim); font-weight: normal; }
.ih-game.ih-game .ih-table tr.ih-current td { background: rgba(127, 251, 255, .12); color: var(--ih-text); }
.ih-kv th { width: 42%; }

/* Any highlight paints a bright background, so its text switches to dark ink. */
.ih-game ::selection { background: var(--ih-yellow); color: var(--ih-ink); }
.ih-game.ih-game mark { background: var(--ih-yellow); color: var(--ih-ink); }
.ih-game.ih-game option, .ih-game.ih-game optgroup { background: var(--ih-bg); color: var(--ih-yellow); }
.ih-game.ih-game option:checked, .ih-game.ih-game option:hover { background: var(--ih-cyan); color: var(--ih-ink); }
.ih-game input:-webkit-autofill, .ih-game input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ih-yellow); caret-color: var(--ih-yellow); box-shadow: 0 0 0 1000px #000 inset;
}

.ih-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--ih-border); }
.ih-row:last-child { border-bottom: 0; }
.ih-warps { display: flex; flex-wrap: wrap; gap: 6px; }
.ih-deploy { margin-top: 10px; }

.ih-news { list-style: none; margin: 0; padding: 0; }
.ih-news li { padding: 5px 0; border-bottom: 1px dashed var(--ih-border); }
.ih-path { display: flex; flex-wrap: wrap; gap: 4px 0; list-style: none; padding: 0; margin: 0 0 1em; }
.ih-path li { padding: 2px 8px; }
.ih-path li + li::before { content: "\2192"; color: var(--ih-dim); margin-right: 8px; }
.ih-game.ih-game .ih-path li.ih-current { color: var(--ih-yellow); }

.ih-msg { border: 1px solid var(--ih-border); border-radius: 3px; padding: 8px 12px; margin-bottom: 8px; }
.ih-msg summary { cursor: pointer; }
.ih-msg.ih-unread { border-color: var(--ih-yellow); }
.ih-msg-body { margin: 10px 0; white-space: normal; }
.ih-game.ih-game .ih-help summary { cursor: pointer; color: var(--ih-yellow); }
.ih-help li { margin-bottom: .5em; }
.ih-help li ul { margin: .4em 0 .4em 1.2em; }
.ih-help li li { margin-bottom: .25em; }

/* Galaxy map */
.ih-map-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ih-map-wrap { border: 1px solid var(--ih-border); background: #000; border-radius: 3px; }
.ih-map { display: block; width: 100%; height: min(70vh, 640px); cursor: grab; touch-action: none; user-select: none; }
.ih-map.ih-dragging { cursor: grabbing; }
.ih-map .ih-e { stroke: #2f7a4a; stroke-width: 1; }
.ih-map .ih-e-oneway { stroke: var(--ih-magenta); stroke-width: 1; stroke-dasharray: 3 2; }
.ih-map .ih-arrow { fill: var(--ih-magenta); }
.ih-map .ih-n { fill: #b9e8c6; stroke: #000; stroke-width: 1; }
.ih-map .ih-n-fed { fill: var(--ih-green); }
.ih-map .ih-n-port { fill: var(--ih-cyan); }
.ih-map .ih-n-special { fill: var(--ih-magenta); }
.ih-map .ih-n-unexplored { fill: #08140c; stroke: #6f9a7c; stroke-width: 1; }
.ih-map .ih-n-charted { stroke: #fff; stroke-width: 1; stroke-dasharray: 2 1.5; fill-opacity: .55; }
.ih-map .ih-n-current { fill: var(--ih-yellow); stroke: #fff; stroke-width: 1.5; }
.ih-map .ih-ring { fill: none; stroke-width: 1.2; }
.ih-map .ih-ring-mine { stroke: var(--ih-green); }
.ih-map .ih-ring-other { stroke: var(--ih-red); }
.ih-map .ih-lbl { fill: var(--ih-dim); font-size: 6px; font-family: var(--ih-font); pointer-events: none; }
.ih-map.ih-zoomed-out .ih-lbl { display: none; }
.ih-map a:hover .ih-n { stroke: var(--ih-yellow); stroke-width: 2; }
.ih-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; margin: 10px 0 0; font-size: .85em; }
.ih-key { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; background: #b9e8c6; border: 1px solid #000; }
.ih-key.ih-n-current { background: var(--ih-yellow); }
.ih-key.ih-n-fed { background: var(--ih-green); }
.ih-key.ih-n-port { background: var(--ih-cyan); }
.ih-key.ih-n-special { background: var(--ih-magenta); }
.ih-key.ih-n-unexplored { background: #08140c; border-color: #6f9a7c; }
.ih-key.ih-n-charted { background: rgba(127, 251, 255, .45); border: 1px dashed #fff; }
.ih-key.ih-ring-mine { background: transparent; border: 2px solid var(--ih-green); }
.ih-key.ih-ring-other { background: transparent; border: 2px solid var(--ih-red); }
.ih-key-line { display: inline-block; width: 18px; border-top: 2px dashed var(--ih-magenta); vertical-align: middle; }

.ih-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; margin-top: 14px; padding: 8px 12px;
  background: var(--ih-panel); border: 1px solid var(--ih-border); border-radius: 4px; font-size: .82em; color: var(--ih-dim); }
.ih-game.ih-game .ih-footer a { color: var(--ih-cyan); text-decoration: none; }
.ih-game.ih-game .ih-footer a:hover { color: var(--ih-yellow); text-decoration: underline; }
.ih-footer .ih-stat { white-space: nowrap; }
.ih-footer-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; }

@media (max-width: 600px) {
  /* A bare number is a small target; pad it out to something a thumb can hit. */
  .ih-game.ih-game .ih-linkish { display: inline-block; padding: 8px 6px; }

  .ih-game { padding: 10px; font-size: 14px; border-radius: 0; }
  .ih-kv th { width: auto; }
  .ih-num { width: 6em; }
  /* 16px stops iOS zooming in on focus; 44px is a comfortable tap target. */
  .ih-game.ih-game input[type=text], .ih-game.ih-game input[type=number], .ih-game.ih-game input[type=password],
  .ih-game.ih-game select, .ih-game.ih-game textarea { font-size: 16px; min-height: 44px; }
  .ih-game.ih-game .ih-btn { min-height: 40px; padding: 9px 14px; }
}

/* DataHouse / Syndicate tag beside a system's class code. */
.ih-game .ih-kind { display: inline-block; padding: 0 6px; border: 1px solid var(--ih-border); border-radius: 3px; font-size: 12px; }
.ih-game .ih-kind-datahouse { color: var(--ih-cyan); }
.ih-game .ih-kind-syndicate { color: var(--ih-green); }
