/* Phone layout: iOS-style home screen and full-screen apps. */

.ios {
  position: fixed;
  inset: 0;
  overflow: hidden;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.ios .doc,
.ios input,
.ios textarea,
.ios .terminal-output,
.ios .folio-message,
.ios .selectable {
  user-select: text;
  -webkit-user-select: text;
}

.ios-home {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 22px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 18px calc(env(safe-area-inset-bottom, 0px) + 172px);
  overflow-y: auto;
}

.ios-widget {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 16px;
  border-radius: 26px;
  text-align: left;
  color: var(--text);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 0.5px 0 var(--glass-shine), inset 0 0 0 0.5px var(--glass-edge), 0 10px 30px rgba(0, 0, 0, 0.18);
}

.ios-profile-card {
  gap: 12px;
}

.ios-profile {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  color: var(--text);
}

.ios-profile-links {
  display: flex;
  gap: 6px;
}

.ios-link-pill {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--fill);
}

.ios-link-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Very narrow phones: icons only (each link keeps its name for screen readers). */
@media (max-width: 359px) {
  .ios-link-label {
    display: none;
  }
}

.ios-link-pill:hover {
  text-decoration: none;
}

.ios-profile-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.ios-profile-text strong {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.ios-profile-text span {
  font-size: 13px;
  color: var(--text-2);
}

.ios-profile-text small {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-3);
}

.ios-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px 8px;
  margin: 0;
  padding: 0 2px;
  list-style: none;
}

.ios-app {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.ios-app .app-icon {
  --size: min(62px, 16vw);
  --icon-shadow: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.26));
}

.ios-app:active .app-icon {
  transform: scale(0.92);
  filter: brightness(0.85) var(--icon-shadow);
}

.ios-home-foot {
  margin: 0;
  text-align: center;
}

.ios-home-foot button {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.18);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.ios-search-pill {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 112px);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.22);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.ios-dock {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  place-items: center;
  height: 90px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.45), inset 0 0 0 0.5px rgba(255, 255, 255, 0.18);
}

/* ---------- App screens ---------- */

.ios-screens {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.ios-screen {
  --surface-2: var(--surface);
  position: absolute;
  inset: 0;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--grouped-bg);
  pointer-events: auto;
  overflow: hidden;
  touch-action: pan-y;
}

.ios-nav {
  position: relative;
  z-index: 2;
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  min-height: calc(46px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 6px 0;
  background: color-mix(in srgb, var(--grouped-bg) 82%, transparent);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 0.5px solid transparent;
  transition: border-color 0.2s var(--ease);
}

.ios-screen.is-scrolled .ios-nav,
.ios-screen.is-app-screen .ios-nav {
  border-bottom-color: var(--hairline);
}

.ios-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0;
  max-width: 100%;
  height: 44px;
  padding: 0 8px 0 2px;
  color: var(--accent-ink);
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ios-title {
  margin: 0;
  max-width: 52vw;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.ios-screen.is-scrolled .ios-title,
.ios-screen.is-app-screen .ios-title {
  opacity: 1;
}

.ios-nav-actions {
  justify-self: end;
  display: flex;
  gap: 6px;
  padding-right: 6px;
}

.ios-nav-actions .btn {
  min-height: 32px;
}

.ios-nav-link {
  padding: 0 8px;
  font-size: 17px;
  color: var(--accent-ink);
}

.ios-screen-body {
  flex: 1;
  min-height: 0;
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ios-screen-body.is-app {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.ios-screen-body.is-app > * {
  flex: 1;
  min-height: 0;
}

.ios-screen-body.is-terminal {
  background: #16181d;
}

.ios-large-title {
  margin: 6px 0 16px;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

/* Screens use the grouped background, so cards need the raised surface. */
.ios-screen .pd-facts > div,
.ios-screen .pd-features li {
  background: var(--surface);
}

.ios-screen .pd-step {
  box-shadow: 0 0 0 4px var(--grouped-bg);
}

/* The large title already names the screen. The document's own title stays in the
   heading outline for screen readers, so later headings don't skip a level. */
.ios-screen .doc-title,
.ios-screen .pd-name {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* The accent tint is see-through; over the grey grouped background it gets too dark
   for the text, so lay it over the card surface as on desktop. */
.ios-screen .pill--accent {
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface);
}

.ios-screen .about-hero {
  background: var(--surface);
}

.ios-screen .doc {
  font-size: 15px;
}

.ios-screen .folio-head {
  padding-left: 16px;
}

.ios-screen .folio-form {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.ios-screen .terminal {
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}

.ios-screen .mail-fields,
.ios-screen .mail-body textarea,
.ios-screen .mail-foot {
  background: var(--surface);
}

.ios-screen .preview {
  padding: 16px 12px calc(24px + env(safe-area-inset-bottom, 0px));
}

.ios-screen .preview > .doc-row {
  justify-content: center;
}

.ios-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.ios-projects {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ios-project {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 10px 10px 14px;
  border-radius: 20px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 0 0 0.5px var(--hairline);
}

.ios-project .cover {
  border-radius: 14px;
}

.ios-project-text {
  display: grid;
  gap: 3px;
  padding: 0 6px;
}

.ios-project-text strong {
  font-size: 17px;
  letter-spacing: -0.01em;
}

.ios-project-text small {
  font-size: 12.5px;
  color: var(--text-3);
}

.ios-project-text span {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.45;
}

.ios-screen .pd {
  padding: 0 0 20px;
}

.ios-group {
  display: grid;
  gap: 6px;
}

.ios-group-title {
  margin: 0;
  padding: 0 14px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-3);
}

.ios-group-body {
  display: grid;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
}

.ios-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 8px 14px;
  font-size: 16px;
  border-top: 0.5px solid var(--hairline);
}

.ios-row:first-child {
  border-top: 0;
}

.ios-row.cc-swatches,
.ios-row.cc-walls {
  justify-content: flex-start;
}

.ios-row.cc-walls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 14px;
}

.ios-row-btn {
  width: 100%;
  text-align: left;
  color: var(--text);
}

.ios-row-btn .icon {
  color: var(--text-3);
}

.ios-note {
  font-size: 13px;
  color: var(--text-3);
}

.ios-foot {
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

.ios-switch {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: var(--fill-2);
  transition: background-color 0.2s var(--ease);
}

.ios-switch span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s var(--ease);
}

.ios-switch[aria-checked="true"] {
  background: #34c759;
}

.ios-switch[aria-checked="true"] span {
  transform: translateX(20px);
}

.ios-indicator {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 180px;
  height: calc(26px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateX(-50%);
}

.ios-indicator span {
  width: 134px;
  height: 5px;
  border-radius: 999px;
  background: var(--text);
  opacity: 0.8;
}

.ios .hud {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 120px);
}

/* Spotlight on a phone: one column, no preview pane. */
.ios ~ .spotlight-layer,
.spotlight-layer.is-phone {
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
}

@media (max-width: 820px) {
  .spotlight-panel {
    grid-template-columns: minmax(0, 1fr);
    max-height: 70vh;
  }
  .spotlight-preview,
  .spotlight-hints {
    display: none;
  }
  .spotlight-layer {
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  }
  .spotlight-bar {
    height: 50px;
  }
  .spotlight-bar input {
    font-size: 17px;
  }
}

/* Shorter phones (iPhone SE and similar): tighten the home screen so it fits above the Dock. */
@media (max-height: 740px) {
  .ios-home {
    gap: 14px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  }
  .ios-widget {
    padding: 14px;
  }
  .ios-grid {
    gap: 12px 8px;
  }
  .ios-app .app-icon {
    --size: min(54px, 15vw);
  }
}
