/* =========================================================
   APP — the phone version: a screen per tab and a floating tab bar at the bottom
   (Home, Works, CV, Contact), like a native app. Everything here waits for
   html.is-app, which the gate in <head> sets before the first paint on phones:
   at most 768px wide, or a touch screen at most 500px tall (a phone on its side).
   Without that class nothing below applies, so the desktop and the tablets stay
   exactly as they are. The tabs themselves: js/app.js. The hero's photos on a
   touch screen: js/touch-hero.js.
   ========================================================= */

/* the app's own pieces, hidden everywhere else */
.tabbar, .works, .contact__copy, .cv-open, .app-back { display: none; }

html.is-app {
  --app-top: env(safe-area-inset-top, 0px);
  --bar-h: 64px;
  --bar-gap: 10px;
  --app-bar: calc(var(--bar-h) + var(--bar-gap) + env(safe-area-inset-bottom, 0px));   /* what the bar covers */
  --app-room: calc(var(--app-bar) + 1.75rem);                                          /* kept free at the end of every screen */
  /* the side margin also clears the notch of a phone on its side */
  --pad: max(1.25rem, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  scroll-snap-type: none;     /* the snap points belong to the desktop's event slides */
  scroll-behavior: auto;      /* js/app.js scrolls on its own terms */
}

/* the top bar, its menu, the reading line and the links the tab bar now stands for */
html.is-app .nav,
html.is-app .menu,
html.is-app .progress,
html.is-app .hero__foot,
html.is-app .hero__hint,
html.is-app #work,
html.is-app .contact__link[href$="#cv"],
html.is-app .foot__top,
html.is-app .crumbs { display: none; }

/* ---------- screens: one at a time ---------- */
html.is-app[data-tab="home"] [data-screen]:not([data-screen="home"]),
html.is-app[data-tab="works"] [data-screen]:not([data-screen="works"]),
html.is-app[data-tab="cv"] [data-screen]:not([data-screen="cv"]),
html.is-app[data-tab="contact"] [data-screen]:not([data-screen="contact"]) { display: none; }

/* changing tab: the new screen comes in, quick and quiet */
html.is-app main.is-entering { animation: appIn 0.26s var(--ease) both; }
@keyframes appIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================
   THE TAB BAR — a pill floating over the page, frosted; the tab you are on has a
   pale yellow pill behind it that slides from tab to tab
   ========================================================= */
html.is-app .tabbar {
  --at: 0;
  position: fixed;
  z-index: 400;
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--bar-gap) + env(safe-area-inset-bottom, 0px));
  max-width: 440px;
  height: var(--bar-h);
  margin-inline: auto;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--print) 74%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid color-mix(in srgb, var(--burgundy) 10%, transparent);
  box-shadow: 0 14px 30px -12px rgba(35, 10, 13, 0.5), 0 2px 6px rgba(35, 10, 13, 0.12);
  view-transition-name: tabbar;      /* it stays put while a project page comes in */
}
html.is-app[data-tab="works"] .tabbar { --at: 1; }
html.is-app[data-tab="cv"] .tabbar { --at: 2; }
html.is-app[data-tab="contact"] .tabbar { --at: 3; }

.tabbar__pill {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  width: calc((100% - 10px) / 4);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--acid) 52%, var(--print));
  transform: translateX(calc(var(--at) * 100%));
  transition: transform 0.45s cubic-bezier(0.3, 1.25, 0.4, 1);   /* a hint of overshoot as it arrives */
}
.tabbar__tab {
  position: relative;
  z-index: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: var(--r-pill);
  color: color-mix(in srgb, var(--burgundy) 58%, transparent);
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  transition: transform 0.18s ease, color 0.3s;
}
.tabbar__tab:active { transform: scale(0.9); }
.tabbar__tab[aria-current="page"] { color: var(--burgundy); }
.tabbar__tab:focus-visible { outline: 2px solid var(--electric-ink); outline-offset: -3px; border-radius: var(--r-pill); }
/* line icons, one weight for all four: the one you are on in the flowers' blue */
.tabbar__ic {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s;
}
.tabbar__tab[aria-current="page"] .tabbar__ic { stroke: var(--electric); }

/* =========================================================
   HOME — the hero fills the screen, the greeting in the middle of what the bar
   leaves; About follows
   ========================================================= */
html.is-app .hero {
  min-height: 100svh;
  padding: calc(var(--app-top) + 1.25rem) var(--pad) var(--app-room);
}
/* a phone on its side: the name is sized by the height too */
html.is-app .hero__name { font-size: min(16.5vw, 22svh); }

/* the greeting comes in after the first photos (js/touch-hero.js adds .has-table; without
   it, a moment after the page): "hi, it's", the name letter by letter, the stickers, the welcome */
html.is-app .hero { --t0: 0.3s; }
html.is-app.has-table .hero { --t0: 0.95s; }
html.is-app .hero__hello { animation-delay: var(--t0); }
html.is-app .hero__name { animation-delay: calc(var(--t0) + 0.9s); }   /* only if its letters were never split (js/app.js) */
html.is-app .hero__name.is-split { animation: none; }
html.is-app .hero__ch {
  display: inline-block;
  animation: appLetter 0.8s var(--ease) calc(var(--t0) + 0.1s + var(--i) * 34ms) both;
}
html.is-app .hero__sticker { animation-delay: calc(var(--t0) + 0.7s + var(--i) * 0.12s), calc(var(--i) * -0.7s); }
html.is-app .hero__welcome { animation-delay: calc(var(--t0) + 0.95s); }
@keyframes appLetter {
  from { opacity: 0; transform: translateY(0.45em); }
  to   { opacity: 1; transform: none; }
}

/* the table (js/touch-hero.js): photos fall in and lie around the name, under it */
.table__img {
  position: absolute;
  display: block;
  width: calc(min(26vw, 21svh) * var(--s, 1));   /* --s: the desktop trail's close sizes */
  height: auto;
  margin: 0;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow-float);
  will-change: transform, opacity;
}
.table__img.is-drop { animation: tableDrop 0.8s cubic-bezier(0.2, 0.8, 0.25, 1) both; }
.table__img.is-tap { animation: tableTap 0.5s cubic-bezier(0.2, 0.8, 0.25, 1) both; }
.table__img.is-out { animation: tableOut 0.7s ease-in-out forwards; }
@keyframes tableDrop {
  0%   { opacity: 0; transform: translate(-50%, -50%) translateY(-16vw) scale(1.16); }
  45%  { opacity: 1; }
  100% { opacity: 1; transform: translate(-50%, -50%); }
}
@keyframes tableTap {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.32); }
  55%  { opacity: 1; }
  100% { opacity: 1; transform: translate(-50%, -50%); }
}
@keyframes tableOut {
  from { opacity: 1; transform: translate(-50%, -50%); }
  to   { opacity: 0; transform: translate(-50%, -50%); }
}
html.is-app .hero.is-table { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
/* the hint, "Tap ✱", low in the hero, over the bar */
html.is-app .hero.is-table .hero__hint {
  display: inline-flex;
  position: absolute;
  left: 50%;
  bottom: calc(var(--app-bar) + 1.1rem);
  translate: -50% 0;
  padding: 0.55em 1em;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--burgundy) 72%, transparent);   /* it stays readable over a photo */
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  white-space: nowrap;
}
html.is-app .hero.is-table.hint-on .hero__hint { opacity: 0.75; }
html.is-app .hero.is-table.hint-gone .hero__hint { opacity: 0; }

/* About: the words still hold while the photo passes under them, without the long
   empty screen after it */
html.is-app .about__stage { padding-block: calc(var(--app-top) + 1.75rem) calc(var(--app-bar) + 1rem); }   /* the words end above the bar */
html.is-app .about__rail { padding-bottom: calc(var(--app-room) + 6svh); }

/* =========================================================
   WORKS — every project and event in one grid, two to a row; a screen shows
   exactly two rows (four cards) between the title and the bar
   ========================================================= */
html.is-app .works {
  --works-head: 4.25rem;     /* the title's row */
  --works-gap: 0.75rem;      /* between cards */
  --works-air: 0.75rem;      /* between the second row and the bar */
  --works-top: calc(var(--app-top) + 0.75rem);
  --rows: 2;
  display: block;
  min-height: 100svh;
  padding: var(--works-top) var(--pad) var(--app-room);
  background: var(--cream);
  color: var(--ink);
  --voice: var(--electric-ink);
  --focus: var(--electric-ink);
}
.works__head { height: var(--works-head); display: flex; align-items: center; }
.works__title {
  font-family: var(--font-text);
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 1;
  letter-spacing: -0.06em;
  color: var(--electric-ink);
}
.works__grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--works-gap);
  /* one card's height: the screen less the space above the grid, the bar, the air
     over the bar and the gaps between the rows, shared by the rows */
  grid-auto-rows: calc((100svh - var(--works-top) - var(--works-head) - var(--app-bar) - var(--works-air) - (var(--rows) - 1) * var(--works-gap)) / var(--rows));
}
.w-card { min-width: 0; min-height: 0; }
.w-card__link {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.45rem;
  -webkit-tap-highlight-color: transparent;
}
.w-card__media {
  position: relative;
  overflow: hidden;
  background: var(--cream-2);
  transition: transform 0.2s var(--ease);
}
.w-card__link:active .w-card__media { transform: scale(0.97); transition-duration: 0.1s; }
.w-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(var(--zoom, 1));      /* the card's own crop, as on the home page */
}
/* Project or Event, since they are mixed: a small label on the picture's corner */
.w-card__tag {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.38em 0.6em;
  border-radius: var(--r-xs);
  background: var(--print);
  color: var(--burgundy);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
  box-shadow: 0 6px 12px -8px rgba(35, 10, 13, 0.6);
}
.w-card--event .w-card__tag { background: var(--burgundy); color: var(--cream); }
.w-card__t {
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.w-card__link:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* =========================================================
   CV — the sheet as on a phone today, the PDF's buttons first
   ========================================================= */
html.is-app .sec--cv { min-height: 100svh; padding: calc(var(--app-top) + 1.75rem) 0 var(--app-room); }
html.is-app .sec--cv .sec__body { display: flex; flex-direction: column; margin-top: 1.4rem; }
html.is-app .cv-cta__wrap {
  order: -1;                                /* above the sheet */
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 4.4rem;                       /* the clip and the photo rise above the sheet */
}
html.is-app .cv-cta__wrap .btn { min-height: 48px; }
html.is-app .cv-open {
  display: inline-flex;
  background: transparent;
  color: var(--cream);
  border-color: color-mix(in srgb, var(--cream) 70%, transparent);
}
html.is-app .cv-open:active { background: color-mix(in srgb, var(--cream) 16%, transparent); }

/* =========================================================
   CONTACT — the title, then big buttons: write, copy the address, LinkedIn
   ========================================================= */
html.is-app .contact {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: calc(var(--app-top) + 2rem) var(--pad) var(--app-room);
}
html.is-app .contact__inner {
  flex: 1;
  justify-content: center;
  align-items: stretch;
  gap: 0.7rem;
  width: 100%;
  max-width: 26rem;
}
html.is-app .contact__title { margin: 0.3rem 0 1.3rem; }
html.is-app .contact__mail,
html.is-app .contact__copy,
html.is-app .contact__link {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 0.85rem 1.25rem;
  border-radius: var(--r-pill);
  font-family: var(--font-text);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;                    /* the desktop's underlined links become buttons */
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background-color 0.25s, color 0.25s;
}
html.is-app .contact__mail { background: var(--acid); color: var(--burgundy); }
html.is-app .contact__link span { margin-left: 0; }
html.is-app .contact__copy,
html.is-app .contact__link {
  background: transparent;
  color: var(--cream);
  border: 1px solid color-mix(in srgb, var(--cream) 45%, transparent);
  cursor: pointer;
}
html.is-app .contact__mail:active,
html.is-app .contact__copy:active,
html.is-app .contact__link:active { transform: scale(0.97); }
html.is-app .contact__copy.is-done { background: var(--cream); color: var(--burgundy); border-color: var(--cream); }
.app-ic { display: none; }
html.is-app .app-ic { display: block; width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html.is-app .foot { margin-top: 2.25rem; justify-content: center; text-align: center; }

/* =========================================================
   A PROJECT PAGE — the same bar (Works lit), a back button at the top,
   no contact block at the end (Contact has its tab)
   ========================================================= */
html.is-app .project-page > .contact { display: none; }
html.is-app .project { padding-top: calc(var(--app-top) + 4.5rem); padding-bottom: var(--app-room); }
html.is-app .app-back {
  position: fixed;
  z-index: 400;
  top: calc(var(--app-top) + 0.75rem);
  left: var(--pad);
  height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0 1rem 0 0.55rem;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--print) 74%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid color-mix(in srgb, var(--burgundy) 10%, transparent);
  box-shadow: 0 10px 24px -12px rgba(35, 10, 13, 0.5);
  color: var(--burgundy);
  font-size: 0.9rem;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease;
  view-transition-name: back;
}
html.is-app .app-back:active { transform: scale(0.94); }
html.is-app .app-back:focus-visible { outline: 2px solid var(--electric-ink); outline-offset: 2px; }
html.is-app .app-back .app-ic { width: 22px; height: 22px; }

/* from a card to its page and back: the page slides in, the bar stays where it is
   (browsers that have cross-page view transitions; others simply load the page) */
@media (max-width: 768px), (hover: none) and (pointer: coarse) and (max-height: 500px) {
  @view-transition { navigation: auto; }
}
::view-transition-old(root) { animation: 0.2s ease both appPageOut; }
::view-transition-new(root) { animation: 0.34s var(--ease) both appPageIn; }
html:active-view-transition-type(back)::view-transition-new(root) { animation-name: appPageBack; }
@keyframes appPageOut { to { opacity: 0; } }
@keyframes appPageIn { from { opacity: 0; transform: translateX(28px); } }
@keyframes appPageBack { from { opacity: 0; transform: translateX(-28px); } }

/* =========================================================
   A PHONE ON ITS SIDE — four cards in one row, a lower title
   ========================================================= */
@media (orientation: landscape) {
  html.is-app .works { --works-head: 3.25rem; --rows: 1; }
  html.is-app .works__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  html.is-app .works__title { font-size: 2rem; }
  html.is-app .hero__hello { font-size: min(2.1rem, 9svh); }
  html.is-app .hero__welcome { font-size: min(1.35rem, 6svh); }
  /* Contact: the title on the left, the buttons beside it, so they are on the first screen */
  html.is-app .contact__inner {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 2.5rem;
    align-content: center;
    max-width: 54rem;
  }
  html.is-app .contact__inner > .eyebrow { grid-column: 1; grid-row: 1; align-self: end; }
  html.is-app .contact__title { grid-column: 1; grid-row: 2 / span 2; align-self: start; font-size: min(5.6vw, 13svh); margin: 0.4rem 0 0; }
  html.is-app .contact__mail { grid-column: 2; grid-row: 1; }
  html.is-app .contact__copy { grid-column: 2; grid-row: 2; }
  html.is-app .contact__link { grid-column: 2; grid-row: 3; }
}

@media (prefers-reduced-motion: reduce) {
  html.is-app main.is-entering { animation: none; }
  html.is-app .hero__ch { animation: none; }
  .tabbar__pill { transition: none; }
  .table__img.is-drop, .table__img.is-tap { animation: none; }
  /* the photos on the phone's table hold still, so they stay: styles.css hides the desktop's moving trail */
  html.is-app .hero.is-table .trail { display: block; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
