/* Translator-specific overrides on top of /shared/theme.css
 *
 * plans/04 §4 C6 — SURGICAL. The only permitted change here is replacing
 * hard-coded values with tokens; selectors, ids and class names are untouched
 * because script.js caches every one of them. Values kept literal are marked
 * with a reason. Physical box offsets (top/right/width/height) are left as
 * they are on purpose: the 1366px block below overrides several of them, and
 * mixing logical overrides onto physical base declarations changes which
 * declaration wins.
 */

body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  /* On a tablet browser 100vh is taller than what is actually on screen. */
  height: 100dvh;
  overflow: hidden;
}

/* The creator credit is styled once, in shared/design/components-kids.css.
   This page stacks controls at z-index 1000+, so it only lifts the chip. */
.creator-name { z-index: 1005; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-grow: 1;
  padding: var(--bb-5);
  gap: var(--bb-3);
  /* Body cannot scroll, so a short viewport would otherwise clip the last row
     of flags away with no way to reach it. */
  overflow-y: auto;
}

.side {
  flex: 1;
  display: flex;
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100%;
  padding: var(--bb-5) 0;
  gap: var(--bb-5);
}

.side:first-child::after {
  content: "";
  position: absolute;
  right: -5.5px;   /* hairline divider, optically centred in the container gap */
  top: 15%;
  height: 70%;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--bb-on-photo-muted), transparent);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);   /* glow on the photo: no token */
  pointer-events: none;
}

.side-top {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: var(--bb-1);
}

.center-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
}

.input-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--bb-3);
  margin-top: var(--bb-3);
}

/* ── Text field ─────────────────────────────────────────────────────────── */
.text-field {
  width: 90%;
  max-width: 600px;
  height: 180px;
  padding: var(--space-md);
  /* The two text fields are the only long-form reading surface in the app, and
     they were set like a headline: 28px at weight 700 with the textarea's
     default line spacing. Bold, tight and large all at once is what made a
     sentence hard to read. Same size, medium weight, room between the lines. */
  font-size: var(--bb-fs-2xl);
  font-weight: 500;
  line-height: 1.45;
  font-family: var(--bb-font);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-md);
  background: var(--surface-warm);
  box-shadow: var(--shadow-sm), inset 0 1px 3px rgba(0, 0, 0, 0.04);   /* inner lip: no token */
  color: var(--text-primary);
  resize: none;
  overflow: auto;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}
.text-field:focus {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm), 0 0 0 3px var(--primary-glow);
  outline: none;
}
.text-field[dir="rtl"] { unicode-bidi: plaintext; }

body.app-busy button:not(.active-action),
body.app-busy .language-grid:not(.active-action) { opacity: 0.6; pointer-events: none; cursor: not-allowed; }
body.app-busy .active-action { opacity: 1; pointer-events: auto; filter: none; cursor: pointer; position: relative; z-index: 1001; }

.translate-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 70px; height: 70px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: var(--bb-on-primary);
  font-size: 32px;   /* icon glyph, sized to the 70px disc; no token */
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--bb-motion-slow) var(--bb-ease-standard),
              box-shadow var(--bb-motion-slow) var(--bb-ease-standard);
  box-shadow: 0 4px 15px var(--primary-glow);
}
.translate-btn i { pointer-events: none; }

/* ── Loader ─────────────────────────────────────────────────────────────── */
.loader {
  color: var(--bb-on-photo-muted);
  width: 30px;
  height: 60px;
  padding-top: 60px;
  box-sizing: border-box;
  display: grid;
  background:
    linear-gradient(currentColor 0 0) bottom/10px calc(100% - 15px),
    conic-gradient(from 134deg at top, #0000, currentColor 1deg 90deg, #0000 91deg) top/100% 15px;
  background-origin: content-box;
  background-repeat: no-repeat;
  animation: l10-0 2s infinite;
  z-index: 900;
}
.loader:before, .loader:after { content: ""; grid-area: 1/1; background: inherit; }
.loader:before { background-size: 10px calc(100% - 25px), 100% 25px; animation: l10-1 2s infinite; }
.loader:after  { background-size: 10px calc(100% - 30px), 100% 30px; animation: l10-2 2s infinite; }

@keyframes l10-0 { 25%, 100% { padding-top: 0 } }
@keyframes l10-1 { 0%, 25% { margin: 60px -10px 0 } 50%, 100% { margin: 8px -10px 0 } }
@keyframes l10-2 { 0%, 50% { margin: 60px -15px 0 } 75%, 100% { margin: 20px -15px 0 } }

/* ── Language grid ──────────────────────────────────────────────────────── */
.language-grid {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--bb-4);
  width: 90%;
  max-width: 600px;
  margin-top: var(--bb-3);
  margin-bottom: var(--bb-5);
}
.side .language-grid { margin-top: var(--bb-5); margin-bottom: var(--bb-5); }

.language-grid button {
  background-color: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  transition: transform var(--bb-motion-base) var(--bb-ease-standard);
}
.side .language-grid .language-option {
  min-width: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--bb-2);
  font-family: var(--bb-font);
}
.language-name {
  max-width: 88px;
  color: var(--text-secondary);
  font-size: var(--bb-fs-sm);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}
.side .language-name { color: var(--bb-on-photo-muted); text-shadow: var(--bb-photo-shadow-sm); }
.language-grid button img { width: 75px; height: 75px; }
.language-grid button.selected img {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--primary-color);
  border-radius: 50%;
  transform: scale(1.1);
  transition: all var(--bb-motion-base) var(--bb-ease-standard);
}

/* .top-controls, .fullscreen-button and the speed control all live in
   shared/design/components-kids.css now: /flashcards wears the same stack. */

/* ── Message dialog ─────────────────────────────────────────────────────── */
.message-dialog {
  position: fixed; inset: 0;
  background: var(--bb-scrim);
  display: flex; justify-content: center; align-items: center;
  z-index: 2000;
  animation: fadeIn var(--bb-motion-base) var(--bb-ease-standard);
}
.message-dialog.hidden { display: none; }

@keyframes fadeIn  { from { opacity: 0; }              to { opacity: 1; } }
@keyframes slideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.message-dialog-content {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-warm) 100%);
  padding: var(--bb-8) var(--bb-12); border-radius: var(--radius-lg);
  text-align: center; box-shadow: var(--shadow-lg);
  max-width: 450px; width: 90%;
  animation: slideIn var(--bb-motion-slow) var(--bb-ease-standard); border: 2px solid var(--surface-border);
}
.message-dialog-icon { font-size: 56px; margin-bottom: var(--bb-4); line-height: 1; color: var(--bb-danger); }
.message-dialog-title { font-size: 24px; font-weight: 700; color: var(--text-primary); margin: 0 0 var(--bb-4); }
.message-dialog-text  { font-size: 16px; line-height: 1.6; color: var(--text-secondary); margin: 0 0 var(--bb-6); }
.message-dialog-btn {
  padding: var(--bb-3) var(--bb-10); font-size: 16px; font-weight: 600; border-radius: var(--radius-md);
  border: none; background: var(--bb-danger);
  color: var(--bb-on-primary); cursor: pointer; transition: all var(--bb-motion-slow) var(--bb-ease-standard);
  box-shadow: var(--shadow-md);
}
.message-dialog-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* ── Tablet optimisations ───────────────────────────────────────────────── */
@media (max-width: 1366px) {
  /* Side gutters keep the panels clear of the two fixed corner controls: the
     bear button on the left, the fullscreen/speed stack on the right. */
  .container {
    flex-direction: row; gap: var(--bb-1); align-items: stretch;
    padding: var(--bb-3) clamp(var(--bb-3), 8vw, 68px);
  }
  .side { padding: var(--bb-4) 0; gap: var(--bb-4); }
  .text-field { width: 90%; font-size: var(--bb-fs-xl); height: clamp(120px, 18vh, 180px); }
  .input-group { gap: var(--bb-2); margin-top: var(--bb-1); }
  .language-grid { width: 95%; gap: var(--bb-3); margin-top: var(--bb-1); margin-bottom: var(--bb-4); }
  .side .language-grid { margin-top: var(--bb-5); margin-bottom: var(--bb-5); }
  /* Flags give way first on a short landscape tablet; the label keeps the
     button well over the 44px touch minimum. */
  .language-grid button img { width: min(60px, 8vh); height: min(60px, 8vh); }
  .side .language-grid .language-option { min-width: 70px; gap: var(--bb-1); }
  .language-name { max-width: 76px; font-size: var(--bb-fs-xs); }
  .translate-btn { width: var(--bb-touch-min); height: var(--bb-touch-min); font-size: var(--bb-fs-2xl); }
  .mic, .play-btn-circle { width: var(--bb-touch-min); height: var(--bb-touch-min); font-size: 24px; }
  /* The width goes on the stack, not the button: the speed control reads the
     same custom property, so sizing the button alone would split the two. */
  .top-controls {
    --bb-top-control-w: 56px;
    transform: scale(0.9); transform-origin: top right;
    top: var(--bb-3); right: var(--bb-3);
  }
  .fullscreen-button { font-size: 24px; }
  /* This page runs out of room well before the shared 700px breakpoint. */
  .creator-name { font-size: var(--bb-fs-xs); inset-block-end: var(--bb-1); inset-inline: 0; margin-inline: auto; inline-size: fit-content; text-align: center; }
}
