/* The browser tabs: the top of a browser window on a black page, a strip of tabs and the bar underneath. The tabs
   are laid out and moved by the script; the active one is an SVG shape with curved feet, redrawn as it moves. */
:root {
  --page: #000000;          /* the page */
  --strip: #17181b;         /* the strip behind the tabs */
  --sheet: #2a2c31;         /* the active tab and the bar under it */
  --hover: #222327;         /* a tab under the pointer */
  --text: #f2f3f5;          /* the active tab's title */
  --dim: #a2a6ae;           /* the other titles, the icons in the bar */
  --rule: #34363c;          /* the thin lines between tabs */
  --field: #1c1d21;         /* the address field */
  --focus: #8db4ff;         /* the focus ring */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--page);
  color: var(--text);
  font-family: 'Geist Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

.stage {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px 16px;
}

/* ---------------------------------------------------------------- the window's top */
.browser {
  position: relative;
  width: min(1000px, 100%);
  border-radius: 14px;
  background: var(--strip);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 40px 80px -30px rgba(80, 110, 180, 0.22), 0 18px 40px -20px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.strip {
  position: relative;
  height: 46px;
  touch-action: pan-y;
}

/* the active tab: one shape whose feet curve out into the bar */
.sheet {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.sheet__body {
  fill: var(--sheet);
}

.sheet__edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 1;
}

.sheet__shade {
  fill: rgba(0, 0, 0, 0.55);
  opacity: 0;
  filter: blur(6px);
  transition: opacity 0.25s ease;
}

.sheet.is-lifted .sheet__edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 1;
}

.sheet__shade {
  opacity: 1;
}

.tabs {
  position: absolute;
  inset: 0;
}

/* ---------------------------------------------------------------- a tab */
.tab {
  position: absolute;
  left: 0;
  top: 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 8px 4px 13px;
  color: var(--dim);
  font-size: 13px;
  font-weight: 450;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: default;
  outline: none;
  will-change: transform;
}

/* the thin line between two tabs, at the tab's left edge */
.tab::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 1px;
  height: 16px;
  background: var(--rule);
  transition: opacity 0.15s ease;
}

.tab.no-rule::before {
  opacity: 0;
}

/* the hover: a rounded box inside the tab, under the content */
.tab::after {
  content: '';
  position: absolute;
  inset: 3px 3px 7px;
  border-radius: 8px;
  background: var(--hover);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.15s ease;
}

@media (hover: hover) {
  .tab:not([aria-selected='true']):hover::after {
    opacity: 1;
  }
}

.tab[aria-selected='true'] {
  color: var(--text);
  z-index: 2;
}

.tab:focus-visible::after {
  opacity: 1;
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--focus);
}

.tab__lean {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
  transform-origin: 50% 100%;
}

.tab__icon {
  flex: none;
  width: 16px;
  height: 16px;
}

.tab__icon svg,
.bar__icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tab__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  /* the title fades out at its end instead of an ellipsis */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 22px), transparent);
  transition: opacity 0.16s ease;
}

.tab__x {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  color: var(--dim);
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.tab__x svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

@media (hover: hover) {
  .tab__x:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
  }
}

.tab__x:active {
  background: rgba(255, 255, 255, 0.16);
}

/* narrow tabs: first the title goes, then the close button (except on the active tab), and the icon centres */
.tab.is-tight .tab__title {
  opacity: 0;
}

.tab.is-tiny {
  padding: 0 0 4px;
  justify-content: center;
}

.tab.is-tiny .tab__lean {
  flex: none;
}

.tab.is-tiny .tab__title {
  display: none;
}

.tab.is-tiny:not([aria-selected='true']) .tab__x {
  display: none;
}

.tab.is-tiny[aria-selected='true'] .tab__icon {
  display: none;
}

.tab.is-dragging {
  z-index: 3;
}

/* ---------------------------------------------------------------- the new tab button */
.plus {
  position: absolute;
  left: 0;
  top: 11px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.2s ease;
  will-change: transform;
  z-index: 2;
}

.plus svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

@media (hover: hover) {
  .plus:hover {
    background: var(--hover);
    color: var(--text);
  }
}

.plus:active {
  background: #2c2e33;
}

.plus:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

.plus[aria-disabled='true'] {
  opacity: 0.35;
  cursor: default;
  background: transparent;
}

/* ---------------------------------------------------------------- the bar under the active tab */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 10px 0 12px;
  background: var(--sheet);
  border-bottom: 1px solid #1f2024;
}

.bar__nav {
  display: flex;
  gap: 4px;
  color: var(--dim);
}

.bar__nav svg {
  width: 28px;
  height: 28px;
  padding: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bar__nav svg:nth-child(2) {
  opacity: 0.4;
}

.bar__address {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 14px;
  border-radius: 16px;
  background: var(--field);
  overflow: hidden;
}

.bar__icon {
  flex: none;
  width: 15px;
  height: 15px;
}

.bar__title {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (max-width: 520px) {
  .bar__nav svg:nth-child(2) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tab__title,
  .sheet__edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 1;
}

.sheet__shade {
    transition: none;
  }
}
