/*
  Flow pages: the franchise form and its confirmation (/basvuru/), the owners' inbox (/gelen/) and the
  KVKK notice (/kvkk/). Measures from the Paper boards: Telefon 390 LU-0, MN-0, NW-0, P8-0, X3-0, XQ-0,
  106-0, 11Z-0 and Masaüstü 1440 16Z-0. Phone boards hold up to 959 px in a centred column at the text
  width; the form switches to the desktop board from 960 px. Square frames, 2 px controls, no shadows.
*/

[hidden] { display: none !important; }

/* ---------- Column ---------- */

.flow-col {
  width: 100%;
  max-width: calc(var(--container-text) + 2 * var(--spacing-gutter));
  margin-inline: auto;
}
.flow-page { padding-bottom: var(--spacing-12); }

/* ---------- Bars ---------- */

/* Back bar: arrow in a 44 px box, 8 px from the edge, then the label (boards LW-0, 107-0, 120-0). */
.flow-bar {
  display: flex;
  align-items: center;
  gap: var(--spacing-1);
  height: 56px;
  padding-left: var(--spacing-2);
  padding-right: var(--spacing-gutter);
}
.flow-back,
.flow-back-box {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
}
.flow-bar-link {
  display: flex;
  align-items: center;
  gap: var(--spacing-1);
  min-height: 44px;
  padding-right: var(--spacing-2);
}
.flow-bar-text {
  font-size: var(--text-control);
  line-height: var(--leading-control);
  font-weight: var(--font-weight-medium);
}
.flow-bar-title { font-weight: var(--font-weight-semibold); }
/* The sage mark closes the back bar on the right (form and KVKK, board LU-0). */
.flow-bar-end { display: flex; margin-left: auto; }

/* Mark bar: sage mark left, one link right (boards X4-0, XR-0). */
.flow-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding-inline: var(--spacing-gutter);
}
.flow-mark { width: 24px; height: 27px; flex-shrink: 0; }
.flow-top-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--text-control);
  line-height: var(--leading-control);
  font-weight: var(--font-weight-medium);
}

/* A standalone link with its line icon; also the look of the inbox's link-like buttons. */
.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-foreground);
  font-size: var(--text-control);
  line-height: var(--leading-control);
  font-weight: var(--font-weight-medium);
  text-align: left;
}

/* ---------- Type ---------- */

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-section-phone);
  line-height: var(--leading-section-phone);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-display);
}
.title {
  font-size: var(--text-title);
  line-height: var(--leading-title);
  font-weight: var(--font-weight-semibold);
}
.body { font-size: var(--text-body); line-height: var(--leading-body); }
.meta {
  font-size: var(--text-meta);
  line-height: var(--leading-meta);
  color: var(--color-muted-foreground);
}
.nowrap { white-space: nowrap; }
.inline-link {
  text-decoration: underline 1px;
  text-underline-offset: 3px;
}

/* ---------- Form ---------- */

.apply-media { display: none; }
.apply-form { padding-bottom: 28px; }

.step { display: flex; flex-direction: column; }
.js .step:not(.is-current) { display: none; }
html:not(.js) .step-next { display: none; }

.step-marker {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-gutter) 0;
}
.step-marker-row {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-3);
  font-size: var(--text-meta);
  line-height: var(--leading-label);
}
.step-marker-name { font-weight: var(--font-weight-semibold); }
.step-marker-count { color: var(--color-muted-foreground); flex-shrink: 0; }
.step-bars { display: flex; gap: var(--spacing-1); }
.step-bar { flex: 1 1 0; height: 3px; background: var(--color-border); }
.step-bar.is-done { background: var(--color-foreground); }

.step-title {
  margin: 28px var(--spacing-gutter) 0;
  font-family: var(--font-display);
  font-size: var(--text-section-phone);
  line-height: var(--leading-section-phone);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-display);
}
.step-title:focus, .done-title:focus, #g-title:focus { outline: none; }

.field {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  margin: var(--spacing-gutter) var(--spacing-gutter) 0;
}
.field-label {
  font-size: var(--text-control);
  line-height: var(--leading-control);
  font-weight: var(--font-weight-medium);
}
.field-help {
  font-size: var(--text-meta);
  line-height: var(--leading-meta);
  color: var(--color-muted-foreground);
}
/* Errors in ink (DESIGN.md): 2 px ink border on the field, the message in 700 under it. */
.field-error, .form-failure {
  font-size: var(--text-meta);
  line-height: var(--leading-meta);
  font-weight: var(--font-weight-semibold);
  color: var(--color-foreground);
}
.form-failure { margin: var(--spacing-3) var(--spacing-gutter) 0; }

.input {
  display: block;
  width: 100%;
  height: var(--spacing-control);
  margin: 0;
  padding: 0 var(--spacing-4);
  background: var(--color-white);
  border: 1px solid rgb(31 42 35 / 40%);
  border-radius: var(--radius-control);
  color: var(--color-foreground);
  font-size: var(--text-control);
  line-height: var(--leading-control);
  appearance: none;
}
.input::placeholder { color: var(--color-muted-foreground); opacity: 1; }
/* Filled fields carry the ink border, empty ones the 40 % ink (boards MD-0 and NR-0). */
.input:not(:placeholder-shown), select.input:valid { border-color: var(--color-foreground); }
select.input:invalid { color: var(--color-muted-foreground); }
select.input option { color: var(--color-foreground); }
.input[aria-invalid="true"] { border-width: 2px; border-color: var(--color-foreground); padding-inline: 15px; }
/* No resize grip (the boards draw none). The note grows with its text: field-sizing where the browser
   has it, elsewhere the page script sets the height on input. */
.textarea {
  height: auto;
  min-height: var(--spacing-control);
  padding-block: 15px;
  resize: none;
}
@supports (field-sizing: content) {
  .textarea { field-sizing: content; }
}
.select { position: relative; display: block; }
.select .input { padding-right: 48px; }
.select .input[aria-invalid="true"] { padding-right: 47px; }
/* The chevron sits 16 px inside the 1 px border (N8-0, 10T-0). */
.select .icon {
  position: absolute;
  right: calc(var(--spacing-4) + 1px);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Choice rows: white boxes, 40 % ink border; the chosen one 2 px ink with a 6 px ring (board MN-0). */
.choice {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  min-height: var(--spacing-control);
  padding-inline: var(--spacing-4);
  background: var(--color-white);
  border: 1px solid rgb(31 42 35 / 40%);
  border-radius: var(--radius-control);
  font-size: var(--text-control);
  line-height: var(--leading-control);
  cursor: pointer;
}
.choice:has(input:checked) { border-width: 2px; border-color: var(--color-foreground); }
/* A group with an error: every box in ink at 1 px, so a chosen box (2 px) still reads apart. */
.choice:has(input[aria-invalid="true"]) { border-color: var(--color-foreground); }
.choice input {
  appearance: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid var(--color-muted-foreground);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.choice input:checked { border: 6px solid var(--color-foreground); }
.choice input:focus-visible { outline: none; }
.choice:has(input:focus-visible) { outline: 2px solid var(--color-sage-deep); outline-offset: 2px; }

.consent-row { display: flex; align-items: flex-start; gap: var(--spacing-3); }
.check {
  appearance: none;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  border: 1.5px solid var(--color-muted-foreground);
  border-radius: var(--radius-control);
  background: var(--color-white);
  cursor: pointer;
}
.check:checked {
  border-color: var(--color-foreground);
  background: var(--color-foreground) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23F5F7F6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.75 12.75L9.75 17.75L19.25 6.75'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
}
.check[aria-invalid="true"] { border: 2px solid var(--color-foreground); }
.consent-text { font-size: 15px; line-height: 23px; cursor: pointer; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: var(--spacing-control);
  margin: 28px var(--spacing-gutter) 0;
  padding: 0 var(--spacing-4);
  background: var(--color-sage-deep);
  border: 0;
  border-radius: var(--radius-control);
  color: var(--color-on-sage);
  font-size: var(--text-control);
  line-height: var(--leading-control);
  font-weight: var(--font-weight-semibold);
}
.btn:disabled { cursor: progress; opacity: 0.72; }

.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Confirmation (board X3-0) ---------- */

.done-body {
  display: flex;
  flex-direction: column;
  padding: var(--spacing-8) var(--spacing-gutter) 0;
}
.done-title {
  font-family: var(--font-display);
  font-size: var(--text-section-phone);
  line-height: var(--leading-section-phone);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-display);
}
.done-code {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  margin-top: var(--spacing-8);
  padding-block: var(--spacing-6);
  border-block: 1px solid var(--color-border);
  container-type: inline-size;
}
/* 44 px on the board; shrinks with the column so the code stays on one line at 320 px. */
.done-code-value {
  font-family: var(--font-display);
  font-size: min(var(--text-numeral-phone), 12.6cqi);
  line-height: 52px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow-wrap: normal;
}
.done-next {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
  margin-top: var(--spacing-8);
}
.done-list { display: flex; flex-direction: column; gap: var(--spacing-4); }
.done-list li {
  display: flex;
  gap: var(--spacing-3);
  font-size: var(--text-body);
  line-height: var(--leading-body);
}
.done-num { flex-shrink: 0; width: 16px; font-weight: var(--font-weight-semibold); }
.done-call { align-self: flex-start; margin-top: var(--spacing-8); }

/* ---------- 404 (board 1UR-0) ---------- */

.nf { display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; }
.nf-home { display: flex; align-items: center; min-height: 44px; }
.nf-body { display: flex; flex-direction: column; padding: var(--spacing-8) var(--spacing-gutter) var(--spacing-8); }
.nf-title {
  font-family: var(--font-display);
  font-size: var(--text-hero-phone);
  line-height: var(--leading-hero-phone);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-display);
}
.nf-text { margin-top: var(--spacing-4); }
.nf-btn { margin: 28px 0 0; }
.nf-links { margin-top: var(--spacing-6); border-top: 1px solid var(--color-border); }
.nf-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-control);
  line-height: var(--leading-control);
  font-weight: var(--font-weight-medium);
}
.nf-links li:last-child a { border-bottom: 0; }
.nf-photo { flex: 1 1 auto; min-height: 240px; position: relative; }
.nf-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; }
@media (min-width: 960px) {
  .nf { flex-direction: row; }
  .nf-col { flex: 1 1 0; max-width: none; margin: 0; padding-inline: clamp(20px, calc((50vw - 440px) * 0.343), 96px); }
  .nf .flow-top { height: 72px; padding: 0; }
  .nf-body { width: 440px; max-width: 100%; padding: var(--spacing-12) 0 var(--spacing-24); }
  .nf-title { font-size: var(--text-section); line-height: var(--leading-section); }
  .nf-photo { flex: 0 0 50%; min-height: 0; height: 100vh; position: sticky; top: 0; }
}

/* ---------- KVKK (board 11Z-0) ---------- */

.kvkk { display: flex; flex-direction: column; padding: var(--spacing-4) var(--spacing-gutter) 0; }
.kvkk-version { margin-top: var(--spacing-2); }
.kvkk-section { display: flex; flex-direction: column; gap: var(--spacing-2); margin-top: var(--spacing-8); }

/* ---------- Inbox list (board XQ-0) ---------- */

#g-csv { gap: var(--spacing-2); }
.g-head {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  padding: var(--spacing-4) var(--spacing-gutter) 0;
}
.g-message { padding: var(--spacing-4) var(--spacing-gutter) 0; }
.g-message:empty { display: none; }
/*
  One row as on the board; when the tabs outgrow a narrow screen the strip scrolls on its own. The 1 px
  rule sits on a wrapper and the strip reaches 4 px past it at the top and bottom, so the scroll box
  keeps a tab's whole focus ring.
*/
.g-tabs-rule {
  margin-top: var(--spacing-6);
  border-bottom: 1px solid var(--color-border);
}
.g-tabs {
  display: flex;
  column-gap: var(--spacing-6);
  margin-block: -4px;
  padding: 4px var(--spacing-gutter);
  overflow-x: auto;
  scrollbar-width: none;
}
.g-tab {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  white-space: nowrap;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-muted-foreground);
  font-size: var(--text-control);
  line-height: var(--leading-control);
  font-weight: var(--font-weight-medium);
}
.g-tab[aria-selected="true"] {
  color: var(--color-foreground);
  font-weight: var(--font-weight-semibold);
  border-bottom: 2px solid var(--color-foreground);
}
.g-list { padding-inline: var(--spacing-gutter); }
.g-empty { padding: var(--spacing-4) var(--spacing-gutter) 0; }
.g-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  padding-block: var(--spacing-4);
  border-bottom: 1px solid var(--color-border);
}
.g-row-text { display: flex; flex: 1 1 0; flex-direction: column; min-width: 0; }
/* Name and status share the line; the status drops under the name only when both do not fit. */
.g-row-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 var(--spacing-3); }
.g-row-name { font-size: var(--text-body); line-height: var(--leading-body); font-weight: var(--font-weight-semibold); }
.g-row-status {
  flex-shrink: 0;
  font-size: var(--text-meta);
  line-height: var(--leading-meta);
  font-weight: var(--font-weight-semibold);
  white-space: pre;
}
.g-row-line { font-size: var(--text-control); line-height: var(--leading-body); }
.g-row-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-3);
  margin-top: var(--spacing-1);
  font-size: var(--text-meta);
  line-height: var(--leading-meta);
  color: var(--color-muted-foreground);
}
.g-row-score { flex-shrink: 0; white-space: pre; }

/* ---------- Inbox detail (board 106-0) ---------- */

.g-actions {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  margin-top: var(--spacing-6);
  padding-inline: var(--spacing-gutter);
}
.g-actions .btn { margin: 0; }
.g-actions .icon-link { align-self: flex-start; }
.g-owner {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
  margin-top: var(--spacing-6);
  padding-inline: var(--spacing-gutter);
}
.g-owner .field { margin: 0; }
.g-owner .input { font-size: var(--text-body); line-height: var(--leading-body); }
.g-note { min-height: 96px; padding: 12px 16px; }
.g-owner .g-note { border-color: var(--color-foreground); }
.g-save:empty { display: none; }
.g-facts {
  display: flex;
  flex-direction: column;
  margin-top: var(--spacing-8);
  padding-inline: var(--spacing-gutter);
}
.g-facts-title { padding-bottom: var(--spacing-2); border-bottom: 1px solid var(--color-border); }
.g-fact {
  display: flex;
  flex-direction: column;
  padding-block: var(--spacing-3);
  border-bottom: 1px solid var(--color-border);
}
.g-fact dt { font-size: var(--text-meta); line-height: var(--leading-meta); color: var(--color-muted-foreground); }
.g-fact dd { font-size: var(--text-body); line-height: var(--leading-body); }
.g-delete { margin: var(--spacing-6) 0 0 var(--spacing-gutter); }
.g-delete-state { padding-inline: var(--spacing-gutter); }

/* ---------- Desktop form (board 16Z-0) ---------- */

@media (min-width: 960px) {
  .apply { display: flex; align-items: flex-start; }
  .apply-media {
    display: block;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    width: 50%;
    height: 100vh;
  }
  .apply-media picture, .apply-media img { width: 100%; height: 100%; }
  .apply-media img { object-fit: cover; object-position: 50% 50%; }
  /* 96 px from the picture at 1440 (board), 20 px at 960 where the 440 px form just fits. */
  .apply-col.flow-col {
    flex: 1 1 0;
    max-width: none;
    margin: 0;
    padding-inline: clamp(20px, calc((50vw - 440px) * 0.343), 96px);
    padding-bottom: var(--spacing-24);
  }
  .apply-form { padding-bottom: 0; }
  .apply .flow-bar { width: 452px; max-width: calc(100% + 12px); height: 72px; margin-left: -12px; padding: 0; }
  .apply .step-marker { width: 440px; max-width: 100%; margin-top: var(--spacing-6); padding: 0; }
  .apply .step-title {
    max-width: 440px;
    margin: var(--spacing-12) 0 0;
    font-size: var(--text-section);
    line-height: var(--leading-section);
  }
  .apply .field { width: 440px; max-width: 100%; margin: var(--spacing-6) 0 0; }
  .apply .step-title + .field { margin-top: var(--spacing-8); }
  .apply .field-label { font-weight: var(--font-weight-semibold); }
  .apply .input, .apply .choice { font-size: var(--text-body); line-height: var(--leading-body); }
  .apply .textarea { padding-block: 11px; }
  .apply .btn { width: 440px; max-width: 100%; margin: var(--spacing-8) 0 0; }
  .apply .form-failure { width: 440px; max-width: 100%; margin: var(--spacing-3) 0 0; }
  /* The confirmation has no desktop board: the phone board X3-0 in the form's 440 px column, title at the form's size. */
  .apply .flow-top { width: 440px; max-width: 100%; height: 72px; padding: 0; }
  .apply .done-body { width: 440px; max-width: 100%; padding: var(--spacing-8) 0 0; }
  .apply .done-title { font-size: var(--text-section); line-height: var(--leading-section); }
}

/* ---------- motion (DESIGN.md, Motion) ---------- */

/* 1. press feedback on buttons */
.btn { transition: transform 160ms var(--ease-out); }
.btn:active:not(:disabled) { transform: scale(0.97); }

/* 4. a step change slides in from the side it comes from (only after Devam or Geri, never on load) */
@keyframes step-next { from { opacity: 0; transform: translateX(16px); } }
@keyframes step-back { from { opacity: 0; transform: translateX(-16px); } }
@keyframes fade-in { from { opacity: 0; } }
.js form[data-dir="next"] .step.is-current { animation: step-next 240ms var(--ease-out) both; }
.js form[data-dir="back"] .step.is-current { animation: step-back 240ms var(--ease-out) both; }

/* 5. the confirmation: title, code and next steps settle in one after another, once */
@keyframes done-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes done-code-in { from { opacity: 0; transform: scale(0.97); } }
.done:not([hidden]) .done-body > * { animation: done-in 360ms var(--ease-out) both; }
.done:not([hidden]) .done-body > .done-code { animation-name: done-code-in; animation-delay: 80ms; }
.done:not([hidden]) .done-body > :nth-child(n + 3) { animation-delay: 160ms; }

@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled) { transform: scale(0.99); }
  .js form[data-dir] .step.is-current,
  .done:not([hidden]) .done-body > *,
  .done:not([hidden]) .done-body > .done-code { animation: fade-in 160ms ease-out both; }
}
