/*
  Styles for find-table.html (იპოვე შენი მაგიდა). Palette, faces and the lozenge
  rule are lifted from style.css so the page reads as part of the invitation,
  but it is a SEPARATE stylesheet: style.css is two thousand lines of opening
  film and hero sky this page has no use for.

  Every .ft-result-* / .ft-table-* / .ft-state--* class is written by
  find-table.js, which sets no colours of its own. Restyling here cannot break
  the data wiring.

  Day tokens on :root, night tokens on html.is-night (set from the invitation's
  'mg-night' preference before first paint). Mobile-first, min-width only; one
  centred column at every width.
*/

/* ==========================================================================
   FONTS: same faces and the same font-display: block bargain as style.css,
   safe only because the loader covers the block period.
   ========================================================================== */
@font-face {
    font-family: 'DM Medea';
    src: url('dm_medea.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'BPG Ucnobi';
    src: url('bpg_ucnobi.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'DM Constitution';
    src: url('dm_constitution.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

/* ==========================================================================
   TOKENS: mirror style.css
   ========================================================================== */
:root {
    --vh: 1vh;

    --paper:   #fbf6ec;
    --paper-2: #f5ede0;
    --paper-3: #eee3d1;
    --cream:   #fffdf8;

    --deep:     #4b4237;
    --ink:      #5d5245;
    --ink-soft: #8b7e6c;
    --gold:     #b48a4e;
    --gold-lt:  #dcc59c;
    --line:     #e4d7c0;
    --shadow:   rgba(110, 82, 44, 0.1);

    /* The invitation's send button, reused for the table pill */
    --pill:     #8f6a3a;
    --pill-ink: #fffcf5;
    --mark:     rgba(220, 197, 156, 0.55);
    --error:    #a8635f;
}

html.is-night {
    --paper:   #121a34;
    --paper-2: #0f1730;
    --paper-3: #0b1227;
    --cream:   #18213f;

    --deep:     #f3ead7;
    --ink:      #d8cfbd;
    --ink-soft: #a39c8e;
    --gold:     #d9b774;
    --gold-lt:  #8b7650;
    --line:     #2b3559;
    --shadow:   rgba(0, 0, 0, 0.3);

    --pill:     #d9b774;
    --pill-ink: #121a34;
    --mark:     rgba(217, 183, 116, 0.3);
    --error:    #e0958f;
}

/* ==========================================================================
   RESET + SCROLLBAR
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scrollbar-width: thin;
    scrollbar-color: var(--gold) var(--paper-2);
}

html::-webkit-scrollbar {
    width: 7px;
}

html::-webkit-scrollbar-track {
    background-color: var(--paper-2);
}

html::-webkit-scrollbar-thumb {
    border-radius: 7px;
    background-color: var(--gold);
}

html,
body {
    overscroll-behavior-y: none;
    background-color: var(--paper);
}

body {
    min-height: 100vh;
    color: var(--ink);
    font-family: 'BPG Ucnobi', Georgia, serif;
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.vh-lock body {
    min-height: calc(var(--vh) * 100);
}

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

button,
input {
    font: inherit;
    color: inherit;
}

/* ==========================================================================
   LOADER
   Dismissed from JS, so <noscript> hides it. inset: 0 only, never a forced
   --vh height, which would oversize it under a mobile tab bar.
   ========================================================================== */
.loader {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--paper);
    transition: opacity 0.6s ease;
}

.loader.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.loader__spinner {
    display: block;
    width: 30px;
    height: 30px;
    border: 1px solid var(--line);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: ft-spin 0.9s linear infinite;
}

@keyframes ft-spin {
    to { transform: rotate(360deg); }
}

/* Held back until the faces are in, so no system-font flash paints */
.ft-page {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 22px 40px;
    opacity: 1;
    transition: opacity 0.5s ease;
}

html.is-loading .ft-page {
    opacity: 0;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.ft-header {
    padding: 26px 0 4px;
    text-align: center;
}

.ft-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 28px;
    font-size: 13px;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    text-decoration: none;
    transition: color 0.3s ease;
}

.ft-back:hover,
.ft-back:active {
    color: var(--gold);
}

/* Chevron from borders, no icon file on a page that has no artwork */
.ft-back__chev {
    width: 7px;
    height: 7px;
    border-left: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: rotate(45deg);
}

.ft-eyebrow {
    font-family: 'DM Constitution', 'BPG Ucnobi', serif;
    font-size: 12.5px;
    letter-spacing: 0.22em;
    color: var(--gold);
}

.ft-title {
    /* Medea's ascenders and descenders run far past its em box: padding, not
       margin, keeps them off the eyebrow and the rule. */
    padding: 10px 0 20px;
    font-family: 'DM Medea', 'BPG Ucnobi', serif;
    font-size: 28px;
    font-weight: normal;
    line-height: 1.8;
    color: var(--deep);
}

/* The invitation's one recurring ornament: a hairline with a lozenge on it */
.ft-rule {
    position: relative;
    display: block;
    width: 84px;
    height: 1px;
    margin: 0 auto 16px;
    background-color: var(--gold-lt);
}

.ft-rule::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    width: 7px;
    height: 7px;
    margin-left: -4px;
    border: 1px solid var(--gold);
    background-color: var(--paper);
    transform: rotate(45deg);
}

.ft-sub {
    font-size: 14.5px;
    line-height: 1.7;
    color: var(--ink-soft);
}

/* ==========================================================================
   SEARCH
   ========================================================================== */
.ft-search-wrap {
    margin-top: 26px;
}

.ft-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 4px 16px;
    background-color: var(--cream);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 6px 20px var(--shadow);
    transition: border-color 0.3s ease;
}

.ft-search-box:focus-within {
    border-color: var(--gold);
}

/* Magnifier drawn from a circle plus one rotated bar */
.ft-search-icon {
    position: relative;
    flex: 0 0 auto;
    width: 13px;
    height: 13px;
    border: 1px solid var(--gold);
    border-radius: 50%;
}

.ft-search-icon::after {
    content: '';
    position: absolute;
    right: -4px;
    bottom: -3px;
    width: 6px;
    height: 1px;
    background-color: var(--gold);
    transform: rotate(45deg);
}

.ft-search-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 12px 0;
    /* 16px exactly: anything smaller makes iOS Safari zoom the page on focus */
    font-size: 16px;
    color: var(--ink);
    background: none;
    border: none;
    outline: none;
}

.ft-search-input::placeholder {
    color: var(--ink-soft);
    opacity: 0.6;
}

.ft-search-input:disabled {
    opacity: 0.55;
}

.ft-clear {
    flex: 0 0 auto;
    display: none;
    width: 34px;
    height: 34px;
    font-size: 13px;
    color: var(--ink-soft);
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.ft-clear.visible {
    display: block;
}

/* Loading / error / not-yet-published. find-table.js writes the modifier. */
.ft-state {
    margin-top: 14px;
    text-align: center;
    font-size: 14px;
    line-height: 1.7;
    color: var(--ink-soft);
}

.ft-state--error {
    color: var(--error);
}

/* ==========================================================================
   RESULTS
   Hidden until there is a query; .visible is added by find-table.js.
   ========================================================================== */
.ft-results {
    display: none;
    margin-top: 28px;
}

.ft-results.visible {
    display: block;
}

.ft-results-label,
.ft-tables-label {
    margin-bottom: 12px;
    text-align: center;
    font-family: 'DM Constitution', 'BPG Ucnobi', serif;
    font-size: 12.5px;
    letter-spacing: 0.22em;
    color: var(--gold);
}

.ft-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 9px;
    padding: 14px 16px 14px 18px;
    background-color: var(--cream);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 4px 16px var(--shadow);
    animation: ft-rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes ft-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.ft-result-name {
    min-width: 0;
    font-size: 16px;
    line-height: 1.5;
    color: var(--deep);
}

.ft-result-name mark {
    color: inherit;
    background-color: var(--mark);
    border-radius: 3px;
}

.ft-result-table {
    flex: 0 0 auto;
    padding: 6px 13px;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--pill-ink);
    background-color: var(--pill);
    border-radius: 999px;
}

.ft-no-results {
    padding: 24px 20px;
    text-align: center;
    font-size: 14.5px;
    line-height: 1.8;
    color: var(--ink-soft);
    background-color: var(--cream);
    border: 1px solid var(--line);
    border-radius: 16px;
}

/* ==========================================================================
   ALL TABLES
   ========================================================================== */
.ft-tables-section {
    margin-top: 34px;
}

/* .ft-tables-section sets no display, but keep [hidden] winning regardless */
.ft-tables-section[hidden] {
    display: none;
}

.ft-tables-grid {
    display: grid;
    gap: 10px;
}

.ft-table-card {
    padding: 14px 18px 15px;
    background-color: var(--cream);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 4px 16px var(--shadow);
}

.ft-table-num {
    font-family: 'DM Medea', 'BPG Ucnobi', serif;
    font-size: 22px;
    line-height: 1.9;
    color: var(--deep);
}

/* The couple's own caption, e.g. "მეგობრები" */
.ft-table-note {
    font-size: 12.5px;
    letter-spacing: 0.06em;
    color: var(--gold);
}

.ft-table-guests {
    margin-top: 8px;
    padding-top: 8px;
    list-style: none;
    border-top: 1px solid var(--line);
}

.ft-table-guests li {
    padding: 4px 0;
    font-size: 15.5px;
    line-height: 1.6;
    color: var(--ink);
}

/* "თანმხლები · <host>" under a companion, written by find-table.js */
.ft-result-host,
.ft-table-host {
    font-size: 12px;
    line-height: 1.4;
    color: var(--ink-soft);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.ft-footer {
    margin-top: 44px;
    padding-top: 26px;
    text-align: center;
    border-top: 1px solid var(--line);
}

.ft-credit {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--ink-soft);
    text-decoration: none;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.ft-credit:hover,
.ft-credit:focus-visible {
    opacity: 0.75;
}

/* Same filters as the invitation's credit: stock blue -> bronze / lamplight gold */
.ft-credit__logo {
    width: 16px;
    height: auto;
    filter: brightness(0) saturate(100%) invert(48%) sepia(38%) saturate(620%) hue-rotate(359deg) brightness(92%);
}

html.is-night .ft-credit__logo {
    filter: brightness(0) saturate(100%) invert(80%) sepia(30%) saturate(620%) hue-rotate(2deg) brightness(98%);
}

/* ==========================================================================
   BREAKPOINTS: mobile-first, min-width only
   ========================================================================== */
@media (min-width: 481px) {
    .ft-page {
        padding: 0 26px 52px;
    }

    .ft-title {
        font-size: 38px;
    }

    .ft-tables-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 769px) {
    .ft-page {
        max-width: 640px;
    }

    .ft-header {
        padding-top: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .loader__spinner { animation-duration: 2.4s; }
    .ft-result-item  { animation: none; }
}
