/* Built by Kyle Bargman: the look of the old Phantasia Ultimate Java client
   (AWT panels, its three colour sets from phantu, phantu1 and phantu2) */

.theme-1 { --fg: rgb(0, 51, 0);   --bg: rgb(255, 255, 204); --hi: rgb(204, 204, 153); }
.theme-2 { --fg: rgb(10, 70, 17); --bg: rgb(240, 236, 199); --hi: rgb(232, 220, 183); }
.theme-3 { --fg: rgb(10, 70, 17); --bg: rgb(182, 182, 250); --hi: rgb(140, 146, 146); }

:root {
  --awt-face: #e4e4e4;
  --awt-light: #ffffff;
  --awt-shadow: #808080;
  --awt-dark: #404040;
  --serif: "Times New Roman", Times, serif;
  --sans: Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #2B528B; color: #000; font: 13px var(--serif); }

#frame { display: flex; flex-direction: column; height: 100%; max-width: 1280px; margin: 0 auto; }

/* the window's title bar */
#titlebar {
  display: flex; align-items: center; gap: 14px; padding: 3px 8px;
  background: #638AC6; color: #000; font: bold 12px var(--sans);
}
#frametitle { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-opt { color: #000; font-weight: normal; font-size: 11px; }
.tb-opt select { font-size: 11px; margin-left: 4px; }
a.tb-opt { text-decoration: underline; color: #000; }

/* the frame: GridBagLayout of the Java client */
#window {
  position: relative; flex: 1; min-height: 0;
  display: grid; gap: 4px; padding: 2px;
  grid-template-columns: minmax(0, 1fr) 210px;
  grid-template-rows: auto minmax(90px, 1fr) auto minmax(110px, 2fr);
  grid-template-areas: "status status" "messages right" "buttons right" "chat right";
  background: var(--bg);
}

/* ---- status pane ---- */
#status {
  grid-area: status;
  display: grid; gap: 4px;
  grid-template-columns: minmax(0, 1fr) 260px;
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "stats head" "stats treasure" "stats equipment";
}
#stats { grid-area: stats; display: grid; grid-template-rows: repeat(4, auto); gap: 4px; }
.stat { background: var(--hi); padding: 0 2px 1px 0; }
.stat-title {
  font: bold 12px var(--sans); color: var(--fg); text-align: center;
  line-height: 14px; padding-bottom: 2px; border-bottom: 1px solid var(--fg); margin-bottom: 2px;
}
.stat-row { display: flex; align-items: center; }
.icon18 { width: 18px; height: 18px; flex: none; margin: 0 2px 0 4px; display: inline-block; }
.num { font: bold 12px var(--sans); color: var(--fg); width: 100px; flex: none; white-space: nowrap; overflow: hidden; }

.bar { position: relative; flex: 1; height: 19px; border: 2px solid var(--fg); background: var(--hi); overflow: hidden; }
.bar-other { position: absolute; left: -2px; top: -2px; bottom: -2px; width: 0; background: rgb(0, 0, 255); }
.bar-fill { position: absolute; left: 2px; top: 2px; bottom: 3px; width: 0; }
.bar-text { position: absolute; left: 0; right: 0; top: 0; text-align: center; font: bold 11px/15px var(--sans); color: var(--fg); }

#head { grid-area: head; background: var(--hi); color: var(--fg); min-height: 38px; text-align: center; padding: 2px 4px; }
#head1 { font: bold 14px/17px var(--serif); }
#head2 { font: 12px/15px var(--sans); }

#treasure { grid-area: treasure; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.tr { background: var(--hi); display: flex; align-items: center; justify-content: space-between; min-height: 20px; }
.tr img { width: auto; height: 18px; margin-left: 1px; }
.tr .num { width: 92px; }

#equipment { grid-area: equipment; display: flex; justify-content: center; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
#equipment img { width: 24px; height: 24px; background: var(--hi); }

/* ---- text areas (AWT TextArea) ---- */
.awt-text {
  display: block; width: 100%; height: 100%; resize: none; margin: 0;
  background: #fff; color: #000; font: 13px/1.25 var(--serif);
  border: 2px inset #c0c0c0; padding: 2px 4px; overflow-y: scroll;
}
#messages { grid-area: messages; }

/* ---- AWT buttons ---- */
button.awt {
  font: 12px var(--serif); color: #000; background: var(--awt-face); cursor: pointer;
  border: 1px solid; border-color: var(--awt-light) var(--awt-dark) var(--awt-dark) var(--awt-light);
  box-shadow: inset -1px -1px 0 var(--awt-shadow); padding: 2px 6px; min-height: 22px;
}
button.awt:active:not(:disabled), button.awt.pressed {
  border-color: var(--awt-dark) var(--awt-light) var(--awt-light) var(--awt-dark);
  box-shadow: inset 1px 1px 0 var(--awt-shadow);
}
button.awt:disabled { color: #9a9a9a; cursor: default; }
button.awt:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }

#buttons { grid-area: buttons; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 1px; }
.btncell { display: flex; flex-direction: column; }
.btncell button { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 2px 2px; }
.btnlabel { position: relative; height: 9px; margin-top: 1px; }
.btnlabel::before { content: ""; position: absolute; left: 0; right: 0; top: 4px; border-top: 1px solid var(--hi); }
.btnlabel::after { content: ""; position: absolute; left: 0; right: 0; top: 2px; height: 5px; border-left: 1px solid var(--hi); border-right: 1px solid var(--hi); }
.btnlabel img { position: relative; z-index: 1; display: block; margin: 0 auto; width: 9px; height: 9px; }

/* ---- chat ---- */
#chat { grid-area: chat; display: flex; flex-direction: column; min-height: 0; }
#chatlog { flex: 1; height: auto; min-height: 0; }
#chatbar { display: flex; gap: 0; margin-top: 2px; }
#chatbar input { flex: 1; min-width: 0; font: 13px var(--serif); border: 2px inset #c0c0c0; padding: 1px 4px; }

/* ---- players and compass ---- */
#right { grid-area: right; display: flex; flex-direction: column; gap: 1px; min-height: 0; }
#users { flex: 1; min-height: 80px; width: 100%; font: 13px var(--serif); border: 2px inset #c0c0c0; background: #fff; }
#users option { padding: 0 2px; }
#compass { display: grid; grid-template-columns: repeat(3, 1fr); }
#compass button { font: bold 12px var(--sans); min-height: 28px; padding: 2px 0; }

/* ---- dialogs (AWT Dialog) ---- */
#dialogs { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.dlg-wrap { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 230px; pointer-events: none; }
.dlg-wrap.modal { pointer-events: auto; background: rgba(0, 0, 0, 0.12); }
.dlg {
  pointer-events: auto; background: var(--awt-face); color: #000; font: 13px var(--sans);
  border: 1px solid #000; box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.45); max-width: calc(100vw - 20px);
}
.dlg-title { background: #638AC6; color: #000; font: bold 12px var(--sans); padding: 3px 8px; min-height: 19px; cursor: move; user-select: none; }
.dlg-body { padding: 10px 14px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dlg-body .line { text-align: center; white-space: pre-wrap; }
.dlg-body input[type=text], .dlg-body input[type=password] { font: 13px var(--sans); border: 2px inset #c0c0c0; padding: 2px 4px; width: 15em; }
.dlg-body select { font: 13px var(--sans); min-width: 12em; }
.dlg-body .field { display: flex; align-items: center; gap: 8px; }
.dlg-body textarea { width: 32em; max-width: calc(100vw - 60px); height: 22em; font: 13px/1.3 var(--sans); border: 2px inset #c0c0c0; resize: both; }
.dlg-body textarea.wide { width: 84ch; font: 12px/1.3 Menlo, Consolas, "Courier New", monospace; white-space: pre; }
.dlg-buttons { display: flex; justify-content: center; gap: 6px; padding: 6px 14px 10px; }
.dlg-buttons button { min-width: 64px; }

/* ---- small screens: stack the panes ---- */
@media (max-width: 760px) {
  #window {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(150px, 1fr) auto auto minmax(120px, 0.8fr);
    grid-template-areas: "status" "messages" "buttons" "right" "chat";
    overflow-y: auto;
  }
  #status { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "stats" "treasure" "equipment"; }
  #buttons { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 3px; }
  #right { flex-direction: row; }
  #users { min-height: 90px; }
  #compass { width: 150px; flex: none; }
  .dlg-wrap { padding-top: 60px; }
  #chatbar input, .dlg-body input { font-size: 16px; }
}
