/* ============================================================
   Dactype — An AI Grapheme Sequencer
   ============================================================ */

/* ---------- Reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* The [hidden] attribute must win over class rules that set `display`
   (e.g. display:flex), otherwise toggling `hidden` in JS has no effect. */
[hidden] {
  display: none !important;
}

:root {
  /* Palette (tweak freely) */
  --color-bg: #2e4a3f;          /* dark green backdrop */
  --color-surface: #ffffff;     /* central card */
  --color-text: #1f2320;
  --color-muted: #6b7f78;
  --color-placeholder-bg: #c6c6c6;
  --color-active-tab-bg: #efeeee;
  --color-inactive-tab-bg: #d9d9d9;
  --color-border: #b9c2be;
  --color-camera-border: #6b7f78;

  --color-tab: #c7d97a;         /* lime yellow-green tabs */
  --color-tab-active: #d6e68c;
  --color-tab-text: #38481a;

  /* Type */
  --font-brand: "Spectral", Georgia, "Times New Roman", serif;
  --font-ui: "Roboto", "Inter", Arial, sans-serif;

  /* Spacing / shape */
  --space: 8px;
  --radius: 6px;
  --card-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 16px 16px 16px 72px; /* extra left room for the hamburger */
}

/* ============================================================
   Central container
   ============================================================ */
.container {
  width: 100%;
  max-width: 1040px;
  height: calc(100vh - 32px);
  background: var(--color-surface);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;

  /* 0.5s fade-in on load */
  opacity: 0;
  animation: fade-in 0.5s ease-out forwards;
}

.container.main {
  width: 100%;
  max-width: 1040px;
  height: calc(100vh - 32px);
  background: var(--color-surface);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* 0.5s fade-in on load */
  opacity: 0;
  animation: fade-in 0.5s ease-out forwards;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   Header (~5%, max 100px)
   ============================================================ */
.app-header {
  flex: 0 0 auto;
  max-height: 100px;
  padding: 20px 20px 5px;
  text-align: left;
}

.app-header__home {
  display: inline-block;
  color: inherit;
  text-decoration: none;
}

.app-header__brand {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: normal;
  line-height: 1.1;
}

.app-header__tagline {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--color-muted);
  letter-spacing: 0.01em;
}

/* ============================================================
   Info mini bar (under the header)
   ============================================================ */
.mini-bar {
  flex: 0 0 auto;
  display: flex;
  gap: 20px;
  padding: 0 20px 5px;
  border-bottom: 1px solid var(--color-border);
}

.mini-bar__link {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  text-decoration: none;
}

.mini-bar__link:hover {
  color: var(--color-tab-text);
  text-decoration: underline;
}

/* ============================================================
   Main working area (~70%)
   ============================================================ */
.app-main {
  flex: 70 1 0;
  min-height: 0;
  display: flex;
  gap: 14px;
  padding: 8px 14px;
}

/* ----- Left column: camera + word input ----- */
.camera-column {
  flex: 2 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.camera {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--color-placeholder-bg);
  border: 1px solid var(--color-camera-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.camera__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  background: transparent;
  color: #4a524d;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
}

.camera__overlay:hover {
  background: rgba(0, 0, 0, 0.04);
}

.camera__overlay-icon {
  display: inline-flex;
  opacity: 0.75;
}

/* Lower-right capture trigger (manual mode) */
.camera__capture {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera__capture:hover {
  background: #ffffff;
}

.word-input {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  background: var(--color-placeholder-bg);
  border: 1px solid var(--color-border);
}

.word-input__field {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  padding: 12px 14px;
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  color: var(--color-text);
}

.word-input__field:focus {
  outline: none;
}

.word-input__field::placeholder {
  color: #5c645f;
}

.word-input__submit {
  flex: 0 0 auto;
  width: 56px;
  border: none;
  border-left: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.word-input__submit:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* ----- Right column: tabbed panel ----- */
.panel-column {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
}

.tab {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-tab-text);
  background: var(--color-tab);
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  opacity: 0.8;
}

.tab--active {
  background: var(--color-tab-active);
  opacity: 1;
}

.panel {
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid var(--color-border);
  background: var(--color-placeholder-bg);
}

.panel__pane {
  height: 100%;
}

.panel__pane[hidden] {
  display: none;
}

.screenshot-list,
.settings {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ----- Gallery (Captures tab) ----- */
.gallery {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  height: 100%;
}

.gallery__subtabs {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  padding: 6px 6px 0;
  background: var(--color-placeholder-bg);
  /* 5px separator strip so scrolling images never touch the tab headers */
  border-bottom: 5px solid var(--color-placeholder-bg);
}

.gallery__subtab {
  flex: 1 1 0;
  padding: 6px 8px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.75rem;
  color: #4a524d;
  background: #cfd4d1;
  border: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
}

.gallery__subtab--active {
  background: #fff;
  color: var(--color-text);
}

.gallery__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.gallery__empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5c645f;
  font-weight: 500;
}

.gallery__item {
  position: relative;
  margin-bottom: 10px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.gallery__thumb {
  display: block;
  width: 100%;
  height: auto;
}

.gallery__actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
}

.gallery__icon-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--color-text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery__icon-btn:hover {
  background: #ffffff;
}

.gallery__icon-btn--danger:hover {
  background: #fff;
  color: #c0392b;
}

.gallery__caption {
  padding: 4px 6px;
  font-size: 0.7rem;
  color: #4a524d;
  word-break: break-all;
}

.gallery__footer {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--color-border);
  background: #fff;
}

.gallery__footer-btn {
  flex: 1 1 0;
  padding: 8px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.gallery__footer-btn:disabled {
  background: #cfd4d1;
  color: #7a827d;
  cursor: not-allowed;
}

.gallery__download-all {
  color: var(--color-tab-text);
  background: var(--color-tab-active);
}

.gallery__download-all:not(:disabled):hover {
  filter: brightness(0.97);
}

.gallery__clear-all {
  color: #fff;
  background: #b0453a;
}

.gallery__clear-all:not(:disabled):hover {
  filter: brightness(0.95);
}

/* ----- Settings tab ----- */
.settings-form {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
}

.settings-form__label {
  font-weight: 600;
  font-size: 0.85rem;
}

.settings-form__select {
  width: 100%;
  padding: 8px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: #fff;
}

.settings-form__panel {
  width: 100%;
}

.settings-form__hint {
  font-size: 0.8rem;
  color: #4a524d;
}

.settings-form__row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.settings-form__interval {
  width: 60px;
  padding: 6px;
  font-family: var(--font-ui);
  border: 1px solid var(--color-border);
  border-radius: 4px;
}

/* ============================================================
   Word output (~22.5%)
   ============================================================ */
.word-output {
  flex: 22.5 1 0;
  min-height: 0;
  margin: 0 14px 3px;
  display: flex;
  align-items: stretch;
  border: 2px solid var(--color-text);
  background: var(--color-surface);
}

.word-output__text {
  flex: 1 1 auto;
  border: none;
  resize: none;
  padding: 14px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1rem;
  text-align: left;
  color: var(--color-text);
  background: transparent;
}

.word-output__text:focus {
  outline: none;
}

.word-output__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* ============================================================
   Footer (~2.5%)
   ============================================================ */
.app-footer {
  flex: 0 0 auto;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-placeholder-bg);
  font-size: 0.75rem;
  color: #4a524d;
}

/* ============================================================
   Hamburger + slide-out menu
   ============================================================ */
.hamburger {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 30;
  width: 40px;
  height: 34px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 2px;
}

.hamburger__bar {
  display: block;
  height: 4px;
  width: 100%;
  background: #ffffff;
  border-radius: 2px;
}

.side-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  width: 260px;
  max-width: 80vw;
  height: 100%;
  background: #24382f;
  color: #fff;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  padding: 16px;
}

.side-menu.is-open {
  transform: translateX(0);
}

.side-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.side-menu__title {
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: 0.1em;
}

.side-menu__close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.side-menu__list {
  list-style: none;
}

.side-menu__list li {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.side-menu__list a {
  display: block;
  padding: 12px 4px;
  color: #e7ece9;
  text-decoration: none;
  font-weight: 500;
}

.side-menu__list a:hover {
  color: var(--color-tab-active);
}

.side-menu__backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.45);
}

/* ============================================================
   Lightbox (About Dactype prompt)
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 0.5s fade-in each time the lightbox is shown */
  animation: fade-in 0.5s ease-out;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.lightbox__dialog {
  position: relative;
  z-index: 1;
  width: 460px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  padding: 24px;
}

.lightbox__brand {
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.6rem;
}

.lightbox__tagline {
  color: var(--color-muted);
  font-weight: 500;
  margin-bottom: 16px;
}

.lightbox__body {
  font-size: 0.9rem;
  color: var(--color-text);
  margin-bottom: 16px;
}

.lightbox__links {
  margin-bottom: 20px;
}

.lightbox__close {
  padding: 8px 20px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-tab-text);
  background: var(--color-tab-active);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.lightbox__close:hover {
  filter: brightness(0.97);
}

/* ============================================================
  ASL Guide (models.html)
  ============================================================ */

.guide-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-direction: column;
  gap: 1px;
  padding: 3px;
  overflow: hidden;
}

.aslguide__img {
  display: flex;
  width: auto;
  height: 100%;
  aspect-ratio: 3/4;
}

/* ============================================================
   Model Information page (models.html)
   ============================================================ */

.models-body {
  flex: 1 1 auto;
  flex-direction: row;
  min-height: 0;
  display: flex;
  padding: 8px 20px 14px;
  overflow: auto;
}

.models-placeholder {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-placeholder-bg);
  border: 1px solid var(--color-camera-border);
}

.models-content {
  flex: 1 1 auto;
  flex-direction: column;
  display: flex;
  padding: 5px;
  background: var(--color-placeholder-bg);
  border: 1px solid var(--color-camera-border);
  height: fit-content;
  min-height: 0;
  padding-bottom: 10px;
}

.models-tab__row {
  flex: 1 1 auto;
  flex-direction: row;
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-self: stretch;
}

.models-tab__label {
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  background: var(--color-inactive-tab-bg);
  border-bottom: 0px;
}

.models-tab__content {
  display: none;
}

.models-tab__details {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 5px;
  gap: 1rem;
}

.models-detail__label {
  flex: 1 1 auto;
  padding:5px;
}

.models-image__row {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  padding: 3px;
  min-width: 0;
  background: white;
}

.models-image__row img {
  max-width: 50%;
  height: auto;
  object-fit: contain;
}

/* Show specific content when corresponding radio is checked */
#tab-ann:checked ~ #info_ann {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-self: self-start;
  justify-content: center;
  padding: 5px;
  background-color: var(--color-active-tab-bg);
}

#tab-cnn:checked ~ #info_cnn {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-self: self-start;
  justify-content: center;
  padding: 5px;
  background-color: var(--color-active-tab-bg);
}

/* Optional: Highlight active tab button */
#tab-ann:checked ~ .models-tab__row label[for="tab-ann"],
#tab-cnn:checked ~ .models-tab__row label[for="tab-cnn"] {
  background-color: var(--color-active-tab-bg);
  font-weight: bold;
}

#info_cnn {
  display: hidden;
}

/* ---------- Shared ---------- */
.placeholder-label {
  color: #5c645f;
  font-weight: 500;
}
