/* ==========================================================================
   Land Pooling 3D — interface styling
   Layout, toolbar, information panel, help bar, responsive rules.
   Contains no dependency on the JavaScript module structure beyond
   the documented hook classes (.is-active, .is-selected, [hidden]).
   ========================================================================== */

:root {
  --ink:            #1d2721;
  --ink-soft:       #55655a;
  --paper:          #f3f1e9;
  --panel:          #ffffff;
  --line:           #d8d6cb;
  --accent:         #3f6b4a;
  --accent-strong:  #2c5136;
  --accent-soft:    #e4ece3;
  --sky-top:        #dbe6ea;
  --shadow:         0 2px 10px rgba(29, 39, 33, .12);
  --radius:         6px;
  --toolbar-h:      auto;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
}

/* ------------------------------- header -------------------------------- */

.app__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 12px 18px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.app__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: .01em;
}

.app__subtitle {
  margin: 2px 0 0;
  font-size: .8rem;
  color: var(--ink-soft);
}

.app__status {
  margin: 0;
  font-size: .75rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------- toolbar ------------------------------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.tool {
  appearance: none;
  min-height: 40px;
  padding: 8px 15px;
  font: inherit;
  font-size: .85rem;
  font-weight: 550;
  color: var(--ink);
  background: #fbfaf6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.tool:hover { background: var(--accent-soft); border-color: #b9c9bb; }

.tool:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.tool.is-active,
.tool[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #fff;
}

.tool--reset { margin-left: auto; }

/* -------------------------------- stage -------------------------------- */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 420px;
}

.viewport {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--sky-top) 0%, #eef0e6 70%, #e6e8dc 100%);
  touch-action: none;       /* camera + drag gestures handled in JS */
  cursor: grab;
}

.viewport.is-dragging { cursor: grabbing; }
.viewport.is-placing  { cursor: crosshair; }

.viewport canvas { display: block; }

.viewport canvas:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

/* --------------------------- information panel ------------------------- */

.info {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 236px;
  max-width: calc(100% - 28px);
  padding: 12px 14px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(2px);
}

.info.is-selected { border-left-color: var(--accent); }

.info__name {
  margin: 0 0 8px;
  font-size: .95rem;
  font-weight: 650;
  line-height: 1.25;
}

.info__rows { margin: 0; }

.info__row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  border-top: 1px dotted var(--line);
  font-size: .8rem;
}

.info__row dt { color: var(--ink-soft); }
.info__row dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

.info__actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}

.info__actions:empty { display: none; }

.info__btn {
  flex: 1 1 0;
  min-height: 34px;
  padding: 6px 8px;
  font: inherit;
  font-size: .75rem;
  font-weight: 550;
  color: var(--ink);
  background: #fbfaf6;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}

.info__btn:hover { background: var(--accent-soft); border-color: #b9c9bb; }

.info__btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.info__hint {
  margin: 9px 0 0;
  font-size: .75rem;
  color: var(--ink-soft);
}

/* ------------------------------ error state ---------------------------- */

.error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 24px;
  text-align: center;
  background: #f7f5ee;
  color: var(--ink);
}

.error p { margin: 0; max-width: 34ch; }
.error[hidden] { display: none; }

/* -------------------------------- help --------------------------------- */

.help {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 9px 18px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: .75rem;
  color: var(--ink-soft);
}

.help b { color: var(--ink); font-weight: 600; }

/* ------------------------------ responsive ----------------------------- */

@media (max-width: 1024px) {
  .info { width: 210px; }
}

@media (max-width: 768px) {
  .app__header { padding: 10px 14px 8px; }
  .toolbar { padding: 9px 14px; gap: 6px; }
  .tool { padding: 8px 12px; font-size: .8rem; }
  .tool--reset { margin-left: 0; }
  .stage { min-height: 360px; }
  .info { width: 190px; padding: 10px 11px; top: 10px; left: 10px; }
  .info__name { font-size: .85rem; }
  .help { padding: 8px 14px; gap: 4px 12px; }
}

@media (max-width: 480px) {
  body { font-size: 14px; }
  .app__subtitle { display: none; }
  .toolbar { justify-content: flex-start; }
  .tool { flex: 1 1 auto; min-width: 88px; text-align: center; }
  .stage { min-height: 300px; }
  .info {
    width: auto;
    right: 10px;
    left: 10px;
    top: 8px;
    padding: 8px 10px;
  }
  .info__rows { display: flex; flex-wrap: wrap; gap: 0 14px; }
  .info__row { border-top: 0; padding: 1px 0; }
  .info__hint { margin-top: 4px; }
  .info__actions { margin-top: 6px; }
  .info__btn { min-height: 32px; }
  .help__item:nth-child(n + 4) { display: none; }
}

@media (max-width: 375px) {
  .tool { min-width: 0; padding: 8px 9px; }
  .help__item:nth-child(n + 3) { display: none; }
}

/* Landscape phones: keep the model area usable. */
@media (max-height: 520px) and (orientation: landscape) {
  .app__subtitle, .help { display: none; }
  .stage { min-height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  .tool { transition: none; }
}
