/* =============================================================
   The Lost Office Tools — Design System
   Shared across the welcome page and every tool subpage.
   ============================================================= */

/* Shared file drag-and-drop affordance — one look for the whole toolbox.
   window.TLOT.enableFileDrop() (main.js) toggles this class on <body> while a
   file is dragged over the page; the dashed frame is non-interactive so it
   never blocks the drop itself. */
body.tlot-dragover::after {
  content: "";
  position: fixed;
  inset: 8px;
  border: 2px dashed var(--brand);
  border-radius: 14px;
  background: color-mix(in srgb, var(--brand) 7%, transparent);
  pointer-events: none;
  z-index: 9999;
}

/* ---- Design tokens ---------------------------------------- */
:root {
  /* Brand palette — a "lost treasure" warm gold against deep slate */
  --brand: #d83b01;          /* Office orange-red */
  --brand-2: #ffb900;        /* treasure gold */
  --brand-grad: linear-gradient(135deg, #d83b01 0%, #ffb900 100%);

  /* Office app accent colors (used by tool badges) */
  --office-word: #2b579a;
  --office-excel: #217346;
  --office-powerpoint: #c43e1c;
  --office-general: #5b5fc7;

  /* Light theme surfaces */
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-soft: #eef0f4;
  --text: #1b1f29;
  --text-soft: #5a6273;
  --border: #e2e5ec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 48px rgba(16, 24, 40, .16);

  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1120px;
  --header-h: 64px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0f1320;
  --bg-elev: #171c2b;
  --bg-soft: #1f2536;
  --text: #eef1f7;
  --text-soft: #9aa3b8;
  --border: #283044;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, .55);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 24px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Utility: fully hide an element. Used by tools (modals, panels, etc.) that
   toggle visibility via classList; !important so it beats a component's own
   display rule (e.g. .modal-overlay { display:flex }). */
.hidden { display: none !important; }

/* ---- Header / nav ----------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  display: block;
  flex: none;
  width: 34px; height: 34px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.brand .brand-text small {
  display: block;
  font-weight: 500;
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav a {
  color: var(--text-soft);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 500;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.05rem;
  transition: background .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: var(--bg-soft); }

.lang-select {
  height: 38px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6273' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: background-color .15s ease, border-color .15s ease;
}
.lang-select:hover { background-color: var(--bg-soft); }
.lang-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

/* ---- Hero ------------------------------------------------- */
.hero {
  position: relative;
  padding: 84px 0 64px;
  text-align: center;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -40% 0 auto 0;
  height: 520px;
  background:
    radial-gradient(60% 60% at 50% 0%, color-mix(in srgb, var(--brand-2) 22%, transparent), transparent 70%),
    radial-gradient(50% 50% at 80% 10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent 70%);
  pointer-events: none;
  z-index: -1;
}
.hero .eyebrow {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 22px;
}
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.1;
  margin: 0 0 18px;
  letter-spacing: -.02em;
}
.hero h1 .accent {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p.lead {
  max-width: 640px;
  margin: 0 auto 32px;
  font-size: 1.15rem;
  color: var(--text-soft);
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 11px;
  font-weight: 600;
  font-size: .98rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { box-shadow: var(--shadow-lg); }
.btn-ghost { background: var(--bg-elev); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-soft); }

/* ---- Section scaffolding ---------------------------------- */
.section { padding: 56px 0; }
.section-head { text-align: center; margin-bottom: 40px; }
.section-head h2 { font-size: 1.9rem; margin: 0 0 10px; letter-spacing: -.01em; }
.section-head p { color: var(--text-soft); margin: 0; font-size: 1.05rem; }

/* Personal notes in the About section */
.about-intro {
  max-width: 720px;
  margin: -16px auto 40px;
  text-align: center;
  color: var(--text-soft);
}
.about-intro p { margin: 0; font-size: 1.08rem; }
.about-intro p + p { margin-top: 14px; font-size: .98rem; }

/* ---- Tool grid + cards ------------------------------------ */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
a.tool-card:hover {
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--border));
}
.tool-card .tool-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 13px;
  font-size: 1.6rem;
  background: var(--bg-soft);
}
.tool-icon svg { width: 30px; height: 30px; display: block; }
.tool-card h3 { margin: 0; font-size: 1.18rem; color: var(--text); }
.tool-card p { margin: 0; color: var(--text-soft); font-size: .95rem; flex: 1; }

.tool-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.badge {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
}
.badge.office-Word { background: var(--office-word); }
.badge.office-Excel { background: var(--office-excel); }
.badge.office-PowerPoint { background: var(--office-powerpoint); }
.badge.office-General { background: var(--office-general); }

.badge-soon {
  background: var(--bg-soft);
  color: var(--text-soft);
  border: 1px solid var(--border);
}

/* Beta/preview: tool is live and clickable, but flagged as in-progress. */
.badge-beta {
  background: var(--brand-2);
  color: #4a3500;
}

.tool-card.is-soon { opacity: .72; cursor: default; }

/* Empty-state shown when no tools are registered yet */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
}
.empty-state .big { font-size: 2.4rem; margin-bottom: 8px; }

/* ---- Tool page chrome ------------------------------------- */
.tool-hero {
  padding: 40px 0 8px;
}
.breadcrumb {
  font-size: .9rem;
  color: var(--text-soft);
  margin-bottom: 18px;
}
.breadcrumb a { color: var(--text-soft); }
.breadcrumb a:hover { color: var(--brand); }
.tool-hero h1 {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 2.1rem;
  margin: 0 0 8px;
}
.tool-hero h1 .tool-icon {
  width: 52px; height: 52px; font-size: 1.6rem;
  display: grid; place-items: center;
  border-radius: 13px; background: var(--bg-soft);
}
.tool-hero p.lead { color: var(--text-soft); font-size: 1.1rem; margin: 0; max-width: 720px; }

.tool-body { padding: 32px 0 64px; }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

/* Generic form helpers usable by tool pages */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 7px; font-size: .92rem; }
.field .hint { font-weight: 400; color: var(--text-soft); font-size: .85rem; }
input[type="text"], input[type="number"], input[type="email"],
input[type="search"], select, textarea {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
textarea { resize: vertical; min-height: 120px; }

/* File-upload privacy notice — use on every tool that accepts a file.
   Pair upload.privacy.* (how the file is handled) with upload.disclaimer. */
.upload-notice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  padding: 12px 14px;
  font-size: .86rem;
  line-height: 1.5;
  color: var(--text-soft);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
}
.upload-notice .upload-privacy { color: var(--text); font-weight: 500; }
.upload-notice .upload-disclaimer { font-size: .8rem; }

/* Server-side error message (rendered by PHP after a failed run) */
.form-error {
  margin: 0 0 18px;
  padding: 12px 14px;
  font-size: .9rem;
  color: #fff;
  background: var(--office-powerpoint);
  border-radius: var(--radius-sm);
}

/* ---- Footer ----------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 32px 0;
  margin-top: 40px;
}
.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--text-soft);
  font-size: .9rem;
}
.site-footer .brand { font-size: .95rem; }
/* Hidden © trigger: looks like ordinary footer text, no link affordance */
#ipTrigger { cursor: default; }

/* ---- Hidden footer IP popup (homepage) -------------------- */
.ippop-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 6, 10, .5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  padding: 20px;
}
.ippop {
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 320px; padding: 16px 18px;
}
.ippop-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ippop-title { font-weight: 700; font-size: .95rem; }
.ippop-x {
  margin-left: auto; background: transparent; border: none;
  color: var(--text-soft); font-size: 20px; line-height: 1;
  cursor: pointer; padding: 0 6px; border-radius: 8px;
}
.ippop-x:hover { color: var(--text); background: var(--bg-soft); }
.ippop-form { display: flex; flex-direction: column; gap: 8px; }
.ippop-label { font-size: 12px; color: var(--text-soft); }
.ippop-row { display: flex; gap: 8px; }
.ippop-input {
  flex: 1 1 auto; min-width: 0; font: inherit; font-size: .9rem;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px;
}
.ippop-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.ippop-go {
  flex: 0 0 auto; font: inherit; font-size: .85rem; font-weight: 600;
  color: #fff; background: var(--brand); border: 1px solid transparent;
  border-radius: 9px; padding: 8px 14px; cursor: pointer;
}
.ippop-go:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.ippop-go:disabled { opacity: .6; cursor: default; }
.ippop-ip {
  margin-top: 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1.05rem; color: var(--text); word-break: break-all; user-select: all;
}
.ippop-ip.err { color: var(--office-powerpoint); font-family: inherit; font-size: .9rem; }
/* feedback list inside the popup (widens while the table is shown) */
.ippop.wide { max-width: 780px; }
.ippop-go.sec { width: 100%; color: var(--brand); background: transparent; border-color: color-mix(in srgb, var(--brand) 55%, var(--border)); }
.ippop-go.sec:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.ippop-fb { margin-top: 12px; }
.ippop-fbcount { font-size: 12px; color: var(--text-soft); margin-bottom: 6px; }
.ippop-fbscroll { max-height: min(52vh, 430px); overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.ippop-fbtable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ippop-fbtable th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  background: var(--bg-soft); color: var(--text-soft); font-weight: 600; font-size: 11.5px;
  padding: 7px 10px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
}
.ippop-fbtable th:hover { color: var(--brand); }
.ippop-fbtable td { padding: 6px 10px; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); vertical-align: top; }
.ippop-fbtable tr:last-child td { border-bottom: none; }
.ippop-fbtable td.c { text-align: center; }
.ippop-fbtable td:nth-child(1), .ippop-fbtable td:nth-child(2) { white-space: nowrap; }
.ippop-fbtable td:nth-child(4) { max-width: 340px; overflow-wrap: anywhere; }

/* ---- Responsive ------------------------------------------- */
@media (max-width: 640px) {
  /* Hide only the homepage's in-page anchors (#tools/#about); keep the
     cross-page "All Office tools" link — it's the sole nav route on subpages. */
  .nav a[href^="#"] { display: none; }
  .hero { padding: 56px 0 40px; }
  .section { padding: 40px 0; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
