/* Windows 95 look. No inline styles anywhere (CSP): everything lives here. */

:root {
  --desktop: #008080;
  --face: #c0c0c0;
  --light: #dfdfdf;
  --highlight: #ffffff;
  --shadow: #808080;
  --dark: #0a0a0a;
  --text: #000000;
  --navy: #000080;
  --title-end: #1084d0;
  --link: #0000ee;
  --visited: #551a8b;
  --error: #a00000;

  /* Bevels: raised (windows, buttons) and sunken (inputs, panels). */
  --raised: inset -1px -1px var(--dark), inset 1px 1px var(--light),
    inset -2px -2px var(--shadow), inset 2px 2px var(--highlight);
  --sunken: inset -1px -1px var(--highlight), inset 1px 1px var(--shadow),
    inset -2px -2px var(--light), inset 2px 2px var(--dark);
  --pressed: inset -1px -1px var(--highlight), inset 1px 1px var(--dark),
    inset -2px -2px var(--light), inset 2px 2px var(--shadow);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Keep the hidden attribute working even on elements we give a display value (e.g. .banner). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--desktop);
  color: var(--text);
  font-family: "Microsoft Sans Serif", "MS Sans Serif", Tahoma, Geneva, sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

/* Desktop and window */

.desktop {
  padding: 2rem 1rem;
}

.window {
  max-width: 40rem;
  margin: 0 auto;
  padding: 3px;
  background: var(--face);
  box-shadow: var(--raised);
}

.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 3px 3px 4px;
  background: linear-gradient(90deg, var(--navy), var(--title-end));
  color: #ffffff;
  font-weight: 700;
}

.title-bar-text {
  letter-spacing: 0.02em;
}

.title-bar-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 14px;
  background: var(--face);
  box-shadow: var(--raised);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.title-bar-close:active {
  box-shadow: var(--pressed);
}

/* Menu bar */

.menu-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 0;
  border-bottom: 1px solid var(--shadow);
  box-shadow: 0 1px 0 var(--highlight);
}

.menu-bar a,
.menu-bar-user {
  padding: 2px 8px;
  color: var(--text);
  text-decoration: none;
}

.menu-bar a:hover,
.menu-bar a:focus-visible {
  background: var(--navy);
  color: #ffffff;
  outline: none;
}

.menu-bar-user {
  margin-left: auto;
  color: var(--shadow);
}

/* Body */

.window-body {
  padding: 12px 14px 16px;
}

main {
  min-height: 6rem;
}

h1,
h2,
h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
}

h2 {
  font-size: 13px;
  margin-top: 16px;
}

p {
  margin: 0 0 10px;
}

a {
  color: var(--link);
}

a:visited {
  color: var(--visited);
}

.muted {
  color: #505050;
}

hr {
  border: 0;
  border-top: 1px solid var(--shadow);
  border-bottom: 1px solid var(--highlight);
  margin: 14px 0;
}

/* Forms */

form {
  margin: 12px 0 0;
}

label {
  display: block;
  margin-bottom: 3px;
}

input:not([type="checkbox"], [type="radio"], [type="hidden"]),
select,
textarea {
  display: block;
  width: 100%;
  padding: 4px 5px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  box-shadow: var(--sunken);
  color: var(--text);
  font: inherit;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 1px dotted var(--text);
  outline-offset: -4px;
}

input::placeholder {
  color: var(--shadow);
}

/* "Remember me": checkbox and its label on one line. */
form p:has(> input[type="checkbox"]) {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

form p:has(> input[type="checkbox"]) label {
  display: inline;
  margin: 0;
}

input[type="checkbox"] {
  width: 13px;
  height: 13px;
  margin: 0;
}

.helptext,
form p > span {
  display: block;
  margin-top: 3px;
  color: #404040;
  font-size: 12px;
}

.errorlist {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  color: var(--error);
}

.errorlist.nonfield {
  margin-bottom: 10px;
  padding: 6px 8px;
  background: #ffffff;
  box-shadow: var(--sunken);
}

/* Buttons */

button,
input[type="submit"] {
  min-width: 75px;
  min-height: 23px;
  padding: 3px 12px;
  border: 0;
  border-radius: 0;
  background: var(--face);
  box-shadow: var(--raised);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button:active,
input[type="submit"]:active {
  box-shadow: var(--pressed);
  padding: 4px 11px 2px 13px;
}

button:focus-visible,
input[type="submit"]:focus-visible {
  outline: 1px dotted var(--text);
  outline-offset: -4px;
}

/* Banners (flash messages, htmx errors) */

.messages {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.banner {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 0 0 6px;
  padding: 6px 8px;
  background: #ffffff;
  box-shadow: var(--sunken);
}

.banner::before {
  flex: none;
  font-weight: 700;
  content: "\2139"; /* info */
  color: var(--navy);
}

.banner-success::before {
  content: "\2714";
  color: #007000;
}

.banner-warning::before {
  content: "\26A0";
  color: #8a6d00;
}

.banner-error::before {
  content: "\2716";
  color: var(--error);
}

/* Temporary announcements fading out (see static/js/app.js). */
.fading {
  opacity: 0;
  transition: opacity 0.6s ease;
}

@media (max-width: 480px) {
  .desktop {
    padding: 0;
  }
}

/* Wider window for pages with tables (e.g. the shot calculator). */
.window.window-wide {
  max-width: 72rem;
}

.note {
  margin-top: 10px;
  color: #404040;
  font-size: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Side window: a second Win95 window docked top-right (browser popover). */
.side-window {
  position: fixed;
  inset: 2rem 1rem auto auto;
  width: min(20rem, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100vh - 4rem);
  margin: 0;
  overflow: auto;
  border: 0;
  color: var(--text);
}

.side-window:popover-open {
  animation: slide-in 0.15s ease-out;
}

@keyframes slide-in {
  from {
    transform: translateX(calc(100% + 1rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  .side-window:popover-open {
    animation: none;
  }
}

button.title-bar-close {
  min-width: 0;
  min-height: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.price-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.price-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.price-item label {
  margin: 0;
}

.dialog-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

/* Input + its "*" override marker. */
.price-field {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.price-list .price-field input {
  width: 8rem;
  text-align: right;
}

.override-mark {
  width: 0.6em;
  color: var(--navy);
  font-weight: 700;
}

/* Keep the space when there's no override, so inputs stay aligned. */
.override-mark.off {
  visibility: hidden;
}

/* Toolbar with dropdown menus. */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 8px;
}

details.menu {
  position: relative;
}

details.menu summary {
  display: inline-block;
  min-height: 23px;
  padding: 3px 12px;
  background: var(--face);
  box-shadow: var(--raised);
  cursor: pointer;
  list-style: none;
}

details.menu summary::-webkit-details-marker {
  display: none;
}

details.menu summary::after {
  content: " \25BE";
}

details.menu[open] summary {
  box-shadow: var(--pressed);
}

.menu-popup {
  position: absolute;
  z-index: 5;
  min-width: 14rem;
  max-height: 20rem;
  overflow: auto;
  margin-top: 2px;
  padding: 4px;
  background: var(--face);
  box-shadow: var(--raised);
}

.menu-popup label {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  padding: 2px 6px;
  white-space: nowrap;
}

.menu-popup label:hover {
  background: var(--navy);
  color: #ffffff;
}

/* Table in a sunken white "list view". */
.list-view {
  overflow-x: auto;
  background: #ffffff;
  box-shadow: var(--sunken);
  padding: 2px;
}

.list-view table {
  width: 100%;
  border-collapse: collapse;
}

.list-view th {
  padding: 3px 6px;
  background: var(--face);
  box-shadow: var(--raised);
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}

.list-view td {
  padding: 2px 6px;
  border-bottom: 1px solid #ececec;
  white-space: nowrap;
}

.list-view .num {
  text-align: right;
}

.list-view tbody tr:hover {
  background: #e8e8f4;
}

.cell-input:not([type="checkbox"]) {
  display: inline-block;
  width: 6.5rem;
  padding: 2px 4px;
  text-align: right;
}

button.row-hide {
  min-width: 0;
  min-height: 0;
  padding: 0 5px;
  line-height: 1.2;
}

button.row-hide:active {
  padding: 1px 4px 0 6px;
}

.pos {
  color: #007000;
}

.neg {
  color: var(--error);
}

/* --- Craft calculator --------------------------------------------------- */

.window-body h2 {
  margin-top: 16px;
}

.item-icon {
  display: inline-block;
  flex: none;
  width: 24px;
  height: 24px;
  vertical-align: middle;
  image-rendering: auto;
}

.item-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.grade {
  padding: 0 4px;
  border: 1px solid var(--shadow);
  color: #404040;
  font-size: 11px;
}

.craft-search {
  position: relative;
  margin-bottom: 4px;
}

.craft-search input[type="search"] {
  max-width: 28rem;
}

.search-results {
  position: absolute;
  z-index: 6;
  width: min(28rem, 100%);
  max-height: 22rem;
  overflow: auto;
  margin: 2px 0 0;
  padding: 2px;
  list-style: none;
  background: #ffffff;
  box-shadow: var(--raised), 2px 2px 0 rgb(0 0 0 / 0.25);
}

.search-results:empty {
  display: none;
}

button.search-result {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 0;
  padding: 2px 6px;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

button.search-result:hover,
button.search-result:focus-visible {
  background: var(--navy);
  color: #ffffff;
}

/* Resource tree */
.tree-view {
  padding: 4px 6px;
}

ul.tree,
ul.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.tree ul {
  margin-left: 11px;
  padding-left: 14px;
  border-left: 1px dotted var(--shadow);
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
}

.tree-qty {
  color: #303030;
}

button.tree-toggle,
.tree-toggle-space {
  flex: none;
  width: 15px;
  height: 15px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  font-family: Tahoma, Geneva, sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
}

button.tree-toggle:active {
  padding: 1px 0 0 1px;
}

.list-view tfoot td {
  border-top: 2px solid var(--shadow);
  border-bottom: 0;
}

.share-box {
  display: block;
  margin-top: 8px;
}

.share-box::before {
  content: none;
}

.share-box input {
  margin-top: 4px;
}
