/* ============================================================
   스마트 나침반
   ============================================================ */

:root {
  --bg: #f7f5ef;
  --card: #ffffff;
  --surface-soft: #f1eee5;

  --line: #dedbd1;

  --text: #242424;
  --muted: #77756d;

  --dark: #30302e;

  --north: #d45248;
  --north-soft: #f8e6e3;

  --good: #438857;
  --warning: #aa792b;
  --error: #a64e47;

  --radius: 22px;
}

/* ============================================================
   RESET
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;

  min-width: 320px;
  min-height: 100vh;

  overflow-x: hidden;

  background: var(--bg);

  color: var(--text);

  font-family:
    -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard',
    'Noto Sans KR', Arial, sans-serif;

  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

/* ============================================================
   PAGE
   ============================================================ */

.compass-page {
  width: min(100%, 560px);

  min-height: 100vh;

  margin: 0 auto;

  padding: max(18px, env(safe-area-inset-top)) 16px
    max(28px, env(safe-area-inset-bottom));
}

/* ============================================================
   HEADER
   ============================================================ */

.compass-header {
  margin-bottom: 15px;
}

.compass-brand {
  display: flex;

  align-items: center;

  gap: 12px;
}

.compass-icon {
  width: 48px;
  height: 48px;

  flex: 0 0 48px;

  display: grid;

  place-items: center;

  border-radius: 15px;

  background: #e9e4d7;

  font-size: 25px;
}

.compass-brand-copy {
  min-width: 0;
}

.title-row {
  display: flex;

  align-items: center;

  gap: 7px;

  flex-wrap: wrap;
}

.compass-brand h1 {
  margin: 0;

  font-size: 22px;

  line-height: 1.25;

  letter-spacing: -0.6px;
}

.compass-brand p {
  margin: 4px 0 0;

  color: var(--muted);

  font-size: 13px;
}

.mobile-badge {
  display: inline-flex;

  align-items: center;

  padding: 3px 7px;

  border-radius: 999px;

  background: #e7f1ff;

  color: #416c98;

  font-size: 9px;

  font-weight: 800;

  white-space: nowrap;
}

/* ============================================================
   MAIN
   ============================================================ */

.compass-main {
  display: flex;

  flex-direction: column;

  gap: 14px;
}

/* ============================================================
   SENSOR MESSAGE
   ============================================================ */

.sensor-message {
  min-height: 31px;

  display: flex;

  align-items: center;
  justify-content: center;

  gap: 7px;

  color: var(--muted);

  font-size: 12px;
}

.sensor-dot {
  width: 8px;
  height: 8px;

  flex: 0 0 8px;

  border-radius: 50%;

  background: #bbb8ae;
}

.sensor-message.is-running .sensor-dot {
  background: #61ad6d;

  box-shadow: 0 0 0 4px rgba(97, 173, 109, 0.12);
}

.sensor-message.is-warning .sensor-dot {
  background: #d99d3a;
}

.sensor-message.is-error .sensor-dot {
  background: #bb5b53;
}

/* ============================================================
   ORIENTATION NOTICE
   ============================================================ */

.orientation-notice {
  padding: 9px 12px;

  border: 1px solid #e7d9b8;

  border-radius: 12px;

  background: #fff7e7;

  color: #87652a;

  text-align: center;

  font-size: 11px;

  line-height: 1.5;
}

/* ============================================================
   CARD
   ============================================================ */

.compass-card {
  padding: 18px;

  overflow: hidden;

  border: 1px solid var(--line);

  border-radius: var(--radius);

  background: var(--card);

  box-shadow: 0 10px 30px rgba(34, 31, 24, 0.055);
}

/* ============================================================
   HEADING
   ============================================================ */

.heading-summary {
  text-align: center;
}

.heading-label {
  display: block;

  margin-bottom: 1px;

  color: var(--muted);

  font-size: 11px;
}

.direction-name {
  display: block;

  font-size: 24px;

  line-height: 1.3;

  letter-spacing: -0.7px;
}

.heading-number-wrap {
  min-height: 51px;

  display: flex;

  align-items: center;
  justify-content: center;
}

.heading-number {
  font-size: 38px;

  line-height: 1;

  font-variant-numeric: tabular-nums;

  letter-spacing: -1.4px;
}

/* ============================================================
   COMPASS STAGE
   ============================================================ */

.compass-stage {
  position: relative;

  width: min(78vw, 326px);

  aspect-ratio: 1 / 1;

  margin: 13px auto 21px;
}

/* ============================================================
   DIAL
   ============================================================ */

.compass-dial {
  position: absolute;

  inset: 0;

  overflow: hidden;

  border: 2px solid #c8c4b8;

  border-radius: 50%;

  background: radial-gradient(
    circle at 42% 35%,
    #faf9f4 0,
    #eeeade 72%,
    #dfd9ca 100%
  );

  box-shadow:
    inset 0 7px 22px rgba(0, 0, 0, 0.07),
    0 6px 18px rgba(40, 37, 30, 0.06);

  transform: rotate(0deg);

  will-change: transform;
}

.dial-ring {
  position: absolute;

  top: 50%;
  left: 50%;

  transform: translate(-50%, -50%);

  border-radius: 50%;
}

.ring-1 {
  width: 82%;
  height: 82%;

  border: 1px solid rgba(56, 54, 49, 0.18);
}

.ring-2 {
  width: 48%;
  height: 48%;

  border: 1px solid rgba(56, 54, 49, 0.14);
}

/* ============================================================
   MAIN DIRECTIONS
   ============================================================ */

.direction-mark,
.direction-sub {
  position: absolute;

  z-index: 5;

  transform: translate(-50%, -50%);

  font-weight: 900;
}

.direction-mark {
  font-size: 22px;
}

.direction-sub {
  color: #77746b;

  font-size: 10px;
}

.direction-mark.north {
  top: 12%;
  left: 50%;

  color: var(--north);
}

.direction-mark.east {
  top: 50%;
  left: 88%;
}

.direction-mark.south {
  top: 88%;
  left: 50%;
}

.direction-mark.west {
  top: 50%;
  left: 12%;
}

.direction-sub.northeast {
  top: 23%;
  left: 77%;
}

.direction-sub.southeast {
  top: 77%;
  left: 77%;
}

.direction-sub.southwest {
  top: 77%;
  left: 23%;
}

.direction-sub.northwest {
  top: 23%;
  left: 23%;
}

/* ============================================================
   DEGREE LABEL
   ============================================================ */

.degree-label {
  position: absolute;

  z-index: 3;

  color: #aaa69c;

  font-size: 8px;

  font-variant-numeric: tabular-nums;

  transform: translate(-50%, -50%);
}

.deg-0 {
  top: 4.5%;
  left: 50%;
}

.deg-45 {
  top: 17%;
  left: 83%;
}

.deg-90 {
  top: 50%;
  left: 95%;
}

.deg-135 {
  top: 83%;
  left: 83%;
}

.deg-180 {
  top: 95%;
  left: 50%;
}

.deg-225 {
  top: 83%;
  left: 17%;
}

.deg-270 {
  top: 50%;
  left: 5%;
}

.deg-315 {
  top: 17%;
  left: 17%;
}

/* ============================================================
   NORTH ARROW
   ============================================================ */

.north-arrow {
  position: absolute;

  z-index: 4;

  top: 50%;
  left: 50%;

  width: 32px;
  height: 138px;

  transform: translate(-50%, -50%);
}

.north-arrow-red {
  position: absolute;

  top: 0;
  left: 50%;

  width: 0;
  height: 0;

  transform: translateX(-50%);

  border-left: 13px solid transparent;

  border-right: 13px solid transparent;

  border-bottom: 69px solid var(--north);
}

.north-arrow-white {
  position: absolute;

  bottom: 0;
  left: 50%;

  width: 0;
  height: 0;

  transform: translateX(-50%);

  border-left: 13px solid transparent;

  border-right: 13px solid transparent;

  border-top: 69px solid #f7f5ef;
}

/* ============================================================
   CENTER
   ============================================================ */

.dial-center {
  position: absolute;

  z-index: 8;

  top: 50%;
  left: 50%;

  width: 28px;
  height: 28px;

  display: grid;

  place-items: center;

  transform: translate(-50%, -50%);

  border: 2px solid #4a4944;

  border-radius: 50%;

  background: #f8f6ef;

  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.dial-center-dot {
  width: 8px;
  height: 8px;

  border-radius: 50%;

  background: #4a4944;
}

/* ============================================================
   FIXED MARKER
   ============================================================ */

.heading-marker {
  position: absolute;

  z-index: 20;

  top: -4px;
  left: 50%;

  width: 28px;
  height: 23px;

  transform: translateX(-50%);

  pointer-events: none;
}

.heading-marker-triangle {
  width: 0;
  height: 0;

  margin: 0 auto;

  border-left: 8px solid transparent;

  border-right: 8px solid transparent;

  border-top: 13px solid #2e2e2b;
}

.fixed-cross {
  position: absolute;

  z-index: 15;

  background: rgba(40, 40, 37, 0.1);

  pointer-events: none;
}

.fixed-cross.horizontal {
  top: 50%;
  left: 4%;

  width: 92%;
  height: 1px;
}

.fixed-cross.vertical {
  top: 4%;
  left: 50%;

  width: 1px;
  height: 92%;
}

/* ============================================================
   INFO GRID
   ============================================================ */

.info-grid {
  display: grid;

  grid-template-columns: repeat(4, minmax(0, 1fr));

  gap: 7px;
}

.info-card {
  min-width: 0;

  padding: 9px 5px;

  border: 1px solid #ece9e0;

  border-radius: 12px;

  background: #faf9f5;

  text-align: center;
}

.info-label {
  display: block;

  margin-bottom: 2px;

  color: var(--muted);

  font-size: 9px;
}

.info-card strong {
  display: block;

  overflow: hidden;

  font-size: 11px;

  font-weight: 800;

  text-overflow: ellipsis;

  white-space: nowrap;
}

/* ============================================================
   DIRECTION GUIDE
   ============================================================ */

.direction-guide {
  display: grid;

  grid-template-columns: repeat(4, 1fr);

  margin-top: 9px;

  padding-top: 9px;

  border-top: 1px solid #efede6;
}

.direction-guide > div {
  text-align: center;
}

.direction-guide strong,
.direction-guide span {
  display: block;
}

.direction-guide strong {
  font-size: 10px;
}

.direction-guide span {
  margin-top: 1px;

  color: var(--muted);

  font-size: 8px;
}

/* ============================================================
   CONTROLS
   ============================================================ */

.compass-controls {
  display: grid;

  grid-template-columns: 1.4fr 1fr;

  gap: 7px;
}

.control-button {
  min-height: 47px;

  padding: 9px 10px;

  border: 1px solid var(--line);

  border-radius: 13px;

  background: #fff;

  color: var(--text);

  cursor: pointer;

  font-size: 12px;

  font-weight: 800;

  -webkit-tap-highlight-color: transparent;
}

.control-button.primary {
  border-color: var(--dark);

  background: var(--dark);

  color: #fff;
}

.control-button:disabled {
  opacity: 0.42;

  cursor: default;
}

/* ============================================================
   CALIBRATION
   ============================================================ */

.calibration-box {
  display: flex;

  align-items: center;

  gap: 12px;

  padding: 13px 14px;

  border: 1px solid #ead4aa;

  border-radius: 15px;

  background: #fff5de;

  color: #775b2b;
}

.calibration-icon {
  width: 40px;
  height: 40px;

  flex: 0 0 40px;

  display: grid;

  place-items: center;

  border-radius: 12px;

  background: rgba(196, 142, 45, 0.12);

  font-size: 24px;

  font-weight: 800;
}

.calibration-box strong {
  display: block;

  font-size: 12px;
}

.calibration-box p {
  margin: 3px 0 0;

  font-size: 10px;

  line-height: 1.5;
}

/* ============================================================
   INFO
   ============================================================ */

.compass-info {
  padding: 15px 16px;

  border: 1px solid #e2ded4;

  border-radius: 16px;

  background: rgba(255, 255, 255, 0.55);

  color: #66635c;

  font-size: 12px;

  line-height: 1.65;
}

.compass-info-title {
  margin-bottom: 6px;

  color: #343431;

  font-weight: 800;
}

.compass-info p {
  margin: 0;
}

.compass-info p + p {
  margin-top: 6px;
}

.info-note {
  color: #8a867b;
}

/* ============================================================
   UNSUPPORTED
   ============================================================ */

.unsupported-box {
  padding: 14px;

  border-radius: 14px;

  background: #f6e9e6;

  color: #935249;

  text-align: center;

  font-size: 12px;

  line-height: 1.6;
}

/* ============================================================
   FOOTER
   ============================================================ */

.compass-footer {
  padding: 20px 0 4px;

  color: #aaa69c;

  text-align: center;

  font-size: 11px;
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 390px) {
  .compass-page {
    padding-left: 12px;
    padding-right: 12px;
  }

  .compass-card {
    padding: 15px;
  }

  .compass-stage {
    width: min(80vw, 300px);
  }

  .direction-name {
    font-size: 22px;
  }

  .heading-number {
    font-size: 35px;
  }

  .info-grid {
    gap: 5px;
  }

  .info-card {
    padding-left: 3px;
    padding-right: 3px;
  }

  .info-card strong {
    font-size: 10px;
  }
}

/* ============================================================
   LANDSCAPE
   ============================================================ */

@media (orientation: landscape) and (max-height: 520px) {
  .compass-stage {
    width: min(66vh, 280px);
  }
}
