/* ============================================================
   Greeklik — Page Translator UI
   Reuses the Greeklik brand tokens from the marketing site.
   ============================================================ */
:root {
  --aegean: #1763B5;
  --aegean-bright: #1A6FC4;
  --deepsea: #0E2A47;
  --marble: #FAF6EE;
  --honey: #E8A53B;
  --stone: #5A6A7E;
  --mist: #8A9AAE;

  --header-h: 68px;
  --footer-h: 60px;
  --line: rgba(14, 42, 71, 0.10);
}

* , *::before, *::after { box-sizing: border-box; }
/* The [hidden] attribute must beat the display rules on overlays/footer below,
   otherwise `el.hidden = true` can't hide a `display:flex` element. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--deepsea);
  background: var(--marble);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* ---------- Buttons (brand liquid-glass, simplified) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 500; font-size: 15px; line-height: 1;
  padding: 12px 22px; border-radius: 13px; border: 0; cursor: pointer;
  color: var(--deepsea); background: rgba(14, 42, 71, 0.05);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.08),
    inset 3px 3px 0.5px -3px rgba(0,0,0,0.9),
    inset -3px -3px 0.5px -3px rgba(0,0,0,0.85),
    inset 1px 1px 1px -0.5px rgba(0,0,0,0.6),
    inset -1px -1px 1px -0.5px rgba(0,0,0,0.6);
  transition: transform 200ms ease, box-shadow 200ms ease, background 200ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--honey); outline-offset: 3px; }
.btn-sm { padding: 9px 16px; font-size: 14px; border-radius: 11px; }
.btn-primary { color: var(--marble); background: var(--aegean); box-shadow: 0 6px 18px rgba(23,99,181,0.28); }
.btn-primary:hover { background: var(--aegean-bright); }

/* ---------- Header ---------- */
.app-header {
  height: var(--header-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 clamp(16px, 3vw, 28px);
  background: rgba(250, 246, 238, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 40;
}
.logo-link img { width: 128px; height: auto; }
.app-title { display: flex; flex-direction: column; line-height: 1.1; border-left: 1px solid var(--line); padding-left: 20px; }
.app-title-main { font-family: 'DM Serif Display', serif; font-size: 20px; color: var(--deepsea); }
.app-title-sub { font-size: 12.5px; color: var(--stone); margin-top: 2px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.status-pill {
  font-size: 12.5px; font-weight: 500; color: var(--stone);
  padding: 6px 12px; border-radius: 999px;
  background: rgba(14,42,71,0.05); border: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.status-pill.is-working { color: var(--aegean); }
.status-pill.is-error { color: #b5451b; background: rgba(181,69,27,0.08); border-color: rgba(181,69,27,0.2); }
.status-pill.is-done { color: #2f7d54; }
.status-pill .spin {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(23,99,181,0.25); border-top-color: var(--aegean);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Translation progress bar (in the right pane label) ---------- */
.progress-wrap { display: inline-flex; align-items: center; gap: 9px; margin-left: 12px; }
.progress-track {
  width: 140px; height: 6px; border-radius: 999px;
  background: rgba(14,42,71,0.10); overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--aegean), var(--aegean-bright));
  transition: width 0.25s ease;
}
.progress-text { font-size: 12px; font-weight: 600; color: var(--aegean); min-width: 40px; }
/* Indeterminate mode (scanned pages: we don't know the block count up front). */
.progress-wrap.is-indeterminate .progress-bar {
  width: 40%;
  animation: indeterminate 1.1s ease-in-out infinite;
  transition: none;
}
@keyframes indeterminate {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

/* ---------- Translated document (right pane) ---------- */
.doc-sheet {
  width: 100%; max-width: 780px; align-self: flex-start;
  background: #fff; border-radius: 8px;
  box-shadow: 0 8px 30px rgba(14,42,71,0.14);
  border: 1px solid var(--line);
  min-height: 100%;
  padding: 56px 64px;
}
.doc-empty {
  height: 100%; min-height: 360px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--stone); gap: 6px;
}
.doc-empty-mark { width: 52px; height: 52px; opacity: 0.35; margin-bottom: 10px; }
.doc-empty-title { font-size: 17px; font-weight: 600; color: var(--deepsea); margin: 0; }
.doc-empty-sub { font-size: 14px; max-width: 380px; line-height: 1.5; margin: 0; }

.doc-body {
  color: var(--deepsea);
  font-size: 16.5px; line-height: 1.7;
  letter-spacing: 0.005em;
}
.doc-body h1 { font-size: 27px; line-height: 1.25; font-weight: 600; margin: 4px 0 18px; }
.doc-body h2 { font-size: 21px; line-height: 1.3; font-weight: 600; margin: 26px 0 12px; color: var(--aegean); }
.doc-body h3 { font-size: 18px; font-weight: 600; margin: 22px 0 10px; }
.doc-body p { margin: 0 0 14px; }
.doc-body ul, .doc-body ol { margin: 0 0 16px; padding-left: 26px; }
.doc-body li { margin: 0 0 7px; }
.doc-body strong { font-weight: 600; }
.doc-body h1:first-child, .doc-body h2:first-child, .doc-body p:first-child { margin-top: 0; }

/* Blinking caret while the translation streams in */
.doc-caret {
  display: inline-block; width: 2px; height: 1.05em; margin-left: 1px;
  vertical-align: text-bottom; background: var(--aegean);
  animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

@media (max-width: 720px) {
  .doc-sheet { padding: 32px 24px; }
}

/* ---------- Workspace / split ---------- */
.workspace {
  position: absolute;
  top: var(--header-h); left: 0; right: 0; bottom: var(--footer-h);
  display: flex; align-items: stretch;
}
body.no-doc .workspace,
body.no-doc .app-footer { visibility: hidden; }

.pane {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--marble);
}
.pane-left { width: 50%; }
.pane-right { flex: 1; border-left: 0; }

.pane-label {
  flex: none;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 18px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--stone);
  background: rgba(14,42,71,0.02); border-bottom: 1px solid var(--line);
}
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-greek { background: var(--aegean); }
.dot-en { background: var(--honey); }
.page-badge {
  margin-left: auto; font-weight: 500; letter-spacing: 0.02em; text-transform: none;
  color: var(--aegean); font-size: 12px;
}

.pane-scroll {
  flex: 1; overflow: auto; padding: 22px;
  display: flex; justify-content: center;
  background:
    linear-gradient(rgba(14,42,71,0.015), rgba(14,42,71,0.015)),
    var(--marble);
}
.canvas-holder {
  position: relative;
  width: fit-content; height: fit-content;
  box-shadow: 0 8px 30px rgba(14,42,71,0.14);
  border-radius: 6px; overflow: hidden;
  background: #fff;
}
.canvas-holder canvas { display: block; }
.canvas-holder .overlay {
  position: absolute; inset: 0; pointer-events: none;
}

/* ---------- Divider ---------- */
.divider {
  flex: none; width: 10px; cursor: col-resize;
  background: transparent; position: relative; z-index: 20;
  display: flex; align-items: center; justify-content: center;
}
.divider::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 50%;
  width: 1px; transform: translateX(-50%);
  background: var(--line);
}
.divider-grip {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 4px; border-radius: 8px;
  background: var(--marble); border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(14,42,71,0.10);
  transition: box-shadow 160ms ease, border-color 160ms ease;
}
.divider-grip span { width: 3px; height: 3px; border-radius: 50%; background: var(--mist); }
.divider:hover .divider-grip,
.divider.is-dragging .divider-grip { border-color: var(--honey); box-shadow: 0 4px 14px rgba(232,165,59,0.35); }
.divider:focus-visible { outline: 2px solid var(--honey); outline-offset: -2px; }
body.is-resizing { cursor: col-resize; user-select: none; }

/* ---------- Footer / pager ---------- */
.app-footer {
  height: var(--footer-h);
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; gap: 20px;
  padding: 0 clamp(16px, 3vw, 28px);
  background: rgba(250, 246, 238, 0.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.pager { display: flex; align-items: center; gap: 6px; }
.pager-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--deepsea); font-size: 20px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: border-color 160ms ease, background 160ms ease;
}
.pager-btn:hover:not(:disabled) { border-color: var(--honey); }
.pager-btn:disabled { opacity: 0.35; cursor: default; }
.pager-info { font-size: 14px; color: var(--stone); font-variant-numeric: tabular-nums; text-align: center; display: inline-flex; align-items: center; gap: 6px; }
.pager-input {
  width: 46px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums;
  color: var(--deepsea); font-family: inherit;
  padding: 5px 4px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; -moz-appearance: textfield;
}
.pager-input::-webkit-outer-spin-button,
.pager-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pager-input:focus { outline: 2px solid var(--honey); outline-offset: 1px; border-color: var(--honey); }
.footer-file { font-size: 13px; color: var(--stone); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 32vw; }
.footer-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.zoom-wrap { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--stone); }
.zoom-wrap input { accent-color: var(--aegean); }

/* ---------- Dropzone / empty ---------- */
.dropzone {
  position: absolute; inset: var(--header-h) 0 0 0; z-index: 30;
  display: none; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(23,99,181,0.06), transparent 60%),
    var(--marble);
}
body.no-doc .dropzone { display: flex; }
.dropzone.is-drag .dropzone-card { border-color: var(--honey); box-shadow: 0 18px 50px rgba(232,165,59,0.25); transform: translateY(-2px); }
.dropzone-card {
  width: min(560px, 92vw); text-align: center;
  background: #fff; border: 1.5px dashed rgba(14,42,71,0.18);
  border-radius: 22px; padding: clamp(30px, 5vw, 52px);
  box-shadow: 0 14px 40px rgba(14,42,71,0.10);
  transition: border-color 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}
.dz-mark {
  width: 66px; height: 66px; margin: 0 auto 22px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(23,99,181,0.08); border-radius: 18px;
}
.dz-mark img { width: 38px; height: 38px; }
.dz-title { font-family: 'DM Serif Display', serif; font-weight: 400; font-size: clamp(26px, 3.6vw, 34px); margin: 0 0 12px; color: var(--deepsea); }
.dz-sub { font-size: 15.5px; line-height: 1.6; color: var(--stone); margin: 0 auto 26px; max-width: 44ch; }
.dz-sub em { color: var(--deepsea); font-style: normal; box-shadow: inset 0 -0.5em 0 rgba(232,165,59,0.22); }
.dz-note { margin: 20px 0 0; font-size: 12.5px; color: var(--mist); }
.dz-note.is-warn { color: #b5451b; }

/* ---------- Overlay text painted onto the translated page ---------- */
.tr-line {
  position: absolute;
  display: flex; align-items: center;
  font-family: 'Inter', sans-serif;
  color: var(--deepsea);
  overflow: hidden;
  white-space: pre;
  line-height: 1;
  transform-origin: left center;
}

/* ---------- Login gate ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 560px at 50% -10%, rgba(23,99,181,0.08), transparent 60%),
    var(--marble);
}
.login-card {
  width: min(400px, 92vw);
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: #fff; border-radius: 22px;
  padding: clamp(30px, 5vw, 44px);
  box-shadow: 0 20px 56px rgba(14,42,71,0.16);
}
.login-logo { width: 150px; height: auto; margin-bottom: 22px; }
.login-title { font-family: 'DM Serif Display', serif; font-weight: 400; font-size: 24px; color: var(--deepsea); margin: 0 0 6px; }
.login-sub { font-size: 14.5px; color: var(--stone); margin: 0 0 24px; }
.login-input {
  width: 100%; font-size: 16px; color: var(--deepsea);
  padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--marble); margin-bottom: 14px;
}
.login-input:focus { outline: 2px solid var(--honey); outline-offset: 1px; border-color: var(--honey); }
.login-btn { width: 100%; }
.login-error { margin: 14px 0 0; font-size: 13.5px; color: #b5451b; }

/* Logout button in header */
.logout-btn {
  border: 1px solid var(--line); background: transparent;
  color: var(--stone); font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}
.logout-btn:hover { border-color: var(--honey); color: var(--deepsea); }

/* ---------- Page picker modal ---------- */
.picker-overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(14,42,71,0.28);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.picker-card {
  width: min(460px, 92vw);
  background: #fff; border-radius: 20px;
  padding: clamp(26px, 4vw, 38px);
  box-shadow: 0 24px 60px rgba(14,42,71,0.28);
  text-align: center;
}
.picker-title {
  font-family: 'DM Serif Display', serif; font-weight: 400;
  font-size: clamp(22px, 3vw, 27px); color: var(--deepsea); margin: 0 0 10px;
}
.picker-sub { font-size: 14.5px; color: var(--stone); margin: 0 0 24px; line-height: 1.55; }
.picker-sub strong { color: var(--deepsea); }
.picker-row {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 26px;
}
.picker-label { font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--stone); }
.picker-input {
  width: 96px; font-size: 22px; font-family: 'DM Serif Display', serif;
  text-align: center; color: var(--deepsea);
  padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--marble);
}
.picker-input:focus { outline: 2px solid var(--honey); outline-offset: 1px; border-color: var(--honey); }
.picker-of { font-size: 14px; color: var(--stone); }
.picker-actions { display: flex; flex-direction: column-reverse; gap: 10px; }
@media (min-width: 420px) {
  .picker-actions { flex-direction: row; justify-content: center; }
}

@media (max-width: 720px) {
  .app-title { display: none; }
  .footer-file { display: none; }
}
